use BookStack\Model;
-/**
- * Class Attribute
- * @package BookStack
- */
class Tag extends Model
{
protected $fillable = ['name', 'value', 'order'];
* @property string $name
* @property Carbon $expires_at
* @property User $user
- * @package BookStack\Api
*/
class ApiToken extends Model implements Loggable
{
* guard with 'remember' functionality removed. Basic auth and event emission
* has also been removed to keep this simple. Designed to be extended by external
* Auth Guards.
- *
- * @package Illuminate\Auth
*/
class ExternalBaseSessionGuard implements StatefulGuard
{
* into the default laravel 'Guard' auth flow. Instead most of the logic is done
* via the Saml2 controller & Saml2Service. This class provides a safer, thin
* version of SessionGuard.
- *
- * @package BookStack\Auth\Access\Guards
*/
class Saml2SessionGuard extends ExternalBaseSessionGuard
{
* Class Ldap
* An object-orientated thin abstraction wrapper for common PHP LDAP functions.
* Allows the standard LDAP functions to be mocked for testing.
- * @package BookStack\Services
*/
class Ldap
{
* Class SocialAccount
* @property string $driver
* @property User $user
- * @package BookStack\Auth
*/
class SocialAccount extends Model implements Loggable
{
/**
* Class User
- * @package BookStack\Auth
* @property string $id
* @property string $name
* @property string $email
<?php namespace BookStack\Entities;
-use BookStack\Entities\Managers\EntityContext;
+use BookStack\Entities\Tools\ShelfContext;
use Illuminate\View\View;
class BreadcrumbsViewComposer
/**
* BreadcrumbsViewComposer constructor.
- * @param EntityContext $entityContextManager
+ * @param ShelfContext $entityContextManager
*/
- public function __construct(EntityContext $entityContextManager)
+ public function __construct(ShelfContext $entityContextManager)
{
$this->entityContextManager = $entityContextManager;
}
* Provides access to the core entity models.
* Wrapped up in this provider since they are often used together
* so this is a neater alternative to injecting all in individually.
- *
- * @package BookStack\Entities
*/
class EntityProvider
{
<?php namespace BookStack\Entities;
-use BookStack\Entities\Managers\BookContents;
-use BookStack\Entities\Managers\PageContent;
+use BookStack\Entities\Tools\BookContents;
+use BookStack\Entities\Tools\PageContent;
use BookStack\Uploads\ImageService;
use DomPDF;
use Exception;
* @property string $description
* @property int $image_id
* @property Image|null $cover
- * @package BookStack\Entities
*/
class Book extends Entity implements HasCoverImage
{
* @property Book $book
* @method Builder whereSlugs(string $bookSlug, string $childSlug)
*/
-class BookChild extends Entity
+abstract class BookChild extends Entity
{
/**
/**
* Class Chapter
* @property Collection<Page> $pages
- * @package BookStack\Entities
*/
class Chapter extends BookChild
{
* @method static Entity|Builder hasPermission(string $permission)
* @method static Builder withLastView()
* @method static Builder withViewCount()
- *
- * @package BookStack\Entities
*/
class Entity extends Ownable
{
*/
public function refreshSlug(): string
{
- $generator = new SlugGenerator($this);
- $this->slug = $generator->generate();
+ $this->slug = (new SlugGenerator)->generate($this);
return $this->slug;
}
}
use BookStack\Actions\ActivityType;
use BookStack\Actions\TagRepo;
use BookStack\Entities\Book;
-use BookStack\Entities\Managers\TrashCan;
+use BookStack\Entities\Tools\TrashCan;
use BookStack\Exceptions\ImageUploadException;
use BookStack\Exceptions\NotFoundException;
use BookStack\Facades\Activity;
use BookStack\Actions\ActivityType;
use BookStack\Entities\Book;
use BookStack\Entities\Bookshelf;
-use BookStack\Entities\Managers\TrashCan;
+use BookStack\Entities\Tools\TrashCan;
use BookStack\Exceptions\ImageUploadException;
use BookStack\Exceptions\NotFoundException;
use BookStack\Facades\Activity;
use BookStack\Actions\ActivityType;
use BookStack\Entities\Book;
use BookStack\Entities\Chapter;
-use BookStack\Entities\Managers\BookContents;
-use BookStack\Entities\Managers\TrashCan;
+use BookStack\Entities\Tools\BookContents;
+use BookStack\Entities\Tools\TrashCan;
use BookStack\Exceptions\MoveOperationException;
use BookStack\Exceptions\NotFoundException;
use BookStack\Facades\Activity;
use BookStack\Entities\Book;
use BookStack\Entities\Chapter;
use BookStack\Entities\Entity;
-use BookStack\Entities\Managers\BookContents;
-use BookStack\Entities\Managers\PageContent;
-use BookStack\Entities\Managers\TrashCan;
+use BookStack\Entities\Tools\BookContents;
+use BookStack\Entities\Tools\PageContent;
+use BookStack\Entities\Tools\TrashCan;
use BookStack\Entities\Page;
use BookStack\Entities\PageRevision;
use BookStack\Exceptions\MoveOperationException;
-<?php namespace BookStack\Entities\Managers;
+<?php namespace BookStack\Entities\Tools;
use BookStack\Entities\Book;
use BookStack\Entities\BookChild;
/**
* BookContents constructor.
- * @param $book
*/
public function __construct(Book $book)
{
-<?php namespace BookStack\Entities\Managers;
+<?php namespace BookStack\Entities\Tools;
use BookStack\Entities\Page;
use DOMDocument;
-<?php namespace BookStack\Entities\Managers;
+<?php namespace BookStack\Entities\Tools;
use BookStack\Entities\Page;
use BookStack\Entities\PageRevision;
-<?php namespace BookStack\Entities\Managers;
+<?php namespace BookStack\Entities\Tools;
use BookStack\Entities\Book;
use BookStack\Entities\Bookshelf;
-use Illuminate\Session\Store;
-class EntityContext
+class ShelfContext
{
- protected $session;
-
protected $KEY_SHELF_CONTEXT_ID = 'context_bookshelf_id';
- /**
- * EntityContextManager constructor.
- */
- public function __construct(Store $session)
- {
- $this->session = $session;
- }
-
/**
* Get the current bookshelf context for the given book.
*/
public function getContextualShelfForBook(Book $book): ?Bookshelf
{
- $contextBookshelfId = $this->session->get($this->KEY_SHELF_CONTEXT_ID, null);
+ $contextBookshelfId = session()->get($this->KEY_SHELF_CONTEXT_ID, null);
if (!is_int($contextBookshelfId)) {
return null;
/**
* Store the current contextual shelf ID.
- * @param int $shelfId
*/
public function setShelfContext(int $shelfId)
{
- $this->session->put($this->KEY_SHELF_CONTEXT_ID, $shelfId);
+ session()->put($this->KEY_SHELF_CONTEXT_ID, $shelfId);
}
/**
*/
public function clearShelfContext()
{
- $this->session->forget($this->KEY_SHELF_CONTEXT_ID);
+ session()->forget($this->KEY_SHELF_CONTEXT_ID);
}
}
class SlugGenerator
{
- protected $entity;
-
- /**
- * SlugGenerator constructor.
- * @param $entity
- */
- public function __construct(Entity $entity)
- {
- $this->entity = $entity;
- }
-
/**
* Generate a fresh slug for the given entity.
* The slug will generated so it does not conflict within the same parent item.
*/
- public function generate(): string
+ public function generate(Entity $entity): string
{
- $slug = $this->formatNameAsSlug($this->entity->name);
- while ($this->slugInUse($slug)) {
+ $slug = $this->formatNameAsSlug($entity->name);
+ while ($this->slugInUse($slug, $entity)) {
$slug .= '-' . substr(md5(rand(1, 500)), 0, 3);
}
return $slug;
* Check if a slug is already in-use for this
* type of model within the same parent.
*/
- protected function slugInUse(string $slug): bool
+ protected function slugInUse(string $slug, Entity $entity): bool
{
- $query = $this->entity->newQuery()->where('slug', '=', $slug);
+ $query = $entity->newQuery()->where('slug', '=', $slug);
- if ($this->entity instanceof BookChild) {
- $query->where('book_id', '=', $this->entity->book_id);
+ if ($entity instanceof BookChild) {
+ $query->where('book_id', '=', $entity->book_id);
}
- if ($this->entity->id) {
- $query->where('id', '!=', $this->entity->id);
+ if ($entity->id) {
+ $query->where('id', '!=', $entity->id);
}
return $query->count() > 0;
-<?php namespace BookStack\Entities\Managers;
+<?php namespace BookStack\Entities\Tools;
use BookStack\Entities\Book;
use BookStack\Entities\Bookshelf;
use Activity;
use BookStack\Actions\ActivityType;
-use BookStack\Entities\Managers\BookContents;
+use BookStack\Entities\Tools\BookContents;
use BookStack\Entities\Bookshelf;
-use BookStack\Entities\Managers\EntityContext;
+use BookStack\Entities\Tools\ShelfContext;
use BookStack\Entities\Repos\BookRepo;
use BookStack\Exceptions\ImageUploadException;
use Illuminate\Http\Request;
protected $bookRepo;
protected $entityContextManager;
- public function __construct(EntityContext $entityContextManager, BookRepo $bookRepo)
+ public function __construct(ShelfContext $entityContextManager, BookRepo $bookRepo)
{
$this->bookRepo = $bookRepo;
$this->entityContextManager = $entityContextManager;
use BookStack\Actions\ActivityType;
use BookStack\Entities\Book;
-use BookStack\Entities\Managers\BookContents;
+use BookStack\Entities\Tools\BookContents;
use BookStack\Entities\Repos\BookRepo;
use BookStack\Exceptions\SortOperationException;
use BookStack\Facades\Activity;
use Activity;
use BookStack\Entities\Book;
-use BookStack\Entities\Managers\EntityContext;
+use BookStack\Entities\Tools\ShelfContext;
use BookStack\Entities\Repos\BookshelfRepo;
use BookStack\Exceptions\ImageUploadException;
use BookStack\Exceptions\NotFoundException;
/**
* BookController constructor.
*/
- public function __construct(BookshelfRepo $bookshelfRepo, EntityContext $entityContextManager, ImageRepo $imageRepo)
+ public function __construct(BookshelfRepo $bookshelfRepo, ShelfContext $entityContextManager, ImageRepo $imageRepo)
{
$this->bookshelfRepo = $bookshelfRepo;
$this->entityContextManager = $entityContextManager;
<?php namespace BookStack\Http\Controllers;
use BookStack\Entities\Book;
-use BookStack\Entities\Managers\BookContents;
+use BookStack\Entities\Tools\BookContents;
use BookStack\Entities\Repos\ChapterRepo;
use BookStack\Exceptions\MoveOperationException;
use BookStack\Exceptions\NotFoundException;
use Activity;
use BookStack\Entities\Book;
-use BookStack\Entities\Managers\PageContent;
+use BookStack\Entities\Tools\PageContent;
use BookStack\Entities\Page;
use BookStack\Entities\Repos\BookRepo;
use BookStack\Entities\Repos\BookshelfRepo;
namespace BookStack\Http\Controllers;
use BookStack\Actions\ActivityType;
-use BookStack\Entities\Managers\TrashCan;
+use BookStack\Entities\Tools\TrashCan;
use BookStack\Notifications\TestEmail;
use BookStack\Uploads\ImageService;
use Illuminate\Http\Request;
<?php namespace BookStack\Http\Controllers;
-use BookStack\Entities\Managers\BookContents;
-use BookStack\Entities\Managers\PageContent;
-use BookStack\Entities\Managers\PageEditActivity;
+use BookStack\Entities\Tools\BookContents;
+use BookStack\Entities\Tools\PageContent;
+use BookStack\Entities\Tools\PageEditActivity;
use BookStack\Entities\Page;
use BookStack\Entities\Repos\PageRepo;
use BookStack\Exceptions\NotFoundException;
namespace BookStack\Http\Controllers;
use BookStack\Entities\ExportService;
-use BookStack\Entities\Managers\PageContent;
+use BookStack\Entities\Tools\PageContent;
use BookStack\Entities\Repos\PageRepo;
use BookStack\Exceptions\NotFoundException;
use Throwable;
<?php namespace BookStack\Http\Controllers;
-use BookStack\Entities\Managers\PageContent;
+use BookStack\Entities\Tools\PageContent;
use BookStack\Entities\Repos\PageRepo;
use BookStack\Exceptions\NotFoundException;
use GatherContent\Htmldiff\Htmldiff;
use BookStack\Actions\ActivityType;
use BookStack\Entities\Deletion;
-use BookStack\Entities\Managers\TrashCan;
+use BookStack\Entities\Tools\TrashCan;
class RecycleBinController extends Controller
{
use BookStack\Entities\Book;
use BookStack\Entities\Bookshelf;
use BookStack\Entities\Entity;
-use BookStack\Entities\Managers\EntityContext;
+use BookStack\Entities\Tools\ShelfContext;
use BookStack\Entities\SearchService;
use BookStack\Entities\SearchOptions;
use Illuminate\Http\Request;
public function __construct(
ViewService $viewService,
SearchService $searchService,
- EntityContext $entityContextManager
+ ShelfContext $entityContextManager
) {
$this->viewService = $viewService;
$this->searchService = $searchService;
use BookStack\Actions\ActivityService;
use BookStack\Actions\ActivityType;
use BookStack\Auth\UserRepo;
-use BookStack\Entities\Managers\TrashCan;
+use BookStack\Entities\Tools\TrashCan;
use BookStack\Entities\Page;
use BookStack\Entities\Repos\PageRepo;
use Carbon\Carbon;
<?php namespace Tests\Entity;
-use BookStack\Entities\Managers\PageContent;
+use BookStack\Entities\Tools\PageContent;
use BookStack\Entities\Page;
use Tests\TestCase;
<?php namespace Tests\Uploads;
-use BookStack\Entities\Managers\TrashCan;
+use BookStack\Entities\Tools\TrashCan;
use BookStack\Entities\Repos\PageRepo;
use BookStack\Uploads\Attachment;
use BookStack\Entities\Page;