diff --git a/app/Actions/Tag.php b/app/Actions/Tag.php index 80a911508..709b1ddeb 100644 --- a/app/Actions/Tag.php +++ b/app/Actions/Tag.php @@ -2,10 +2,6 @@ use BookStack\Model; -/** - * Class Attribute - * @package BookStack - */ class Tag extends Model { protected $fillable = ['name', 'value', 'order']; diff --git a/app/Api/ApiToken.php b/app/Api/ApiToken.php index 91c407fd8..defaa7e95 100644 --- a/app/Api/ApiToken.php +++ b/app/Api/ApiToken.php @@ -14,7 +14,6 @@ use Illuminate\Support\Carbon; * @property string $name * @property Carbon $expires_at * @property User $user - * @package BookStack\Api */ class ApiToken extends Model implements Loggable { diff --git a/app/Auth/Access/Guards/ExternalBaseSessionGuard.php b/app/Auth/Access/Guards/ExternalBaseSessionGuard.php index f3d05366d..9a0c691c8 100644 --- a/app/Auth/Access/Guards/ExternalBaseSessionGuard.php +++ b/app/Auth/Access/Guards/ExternalBaseSessionGuard.php @@ -15,8 +15,6 @@ use Illuminate\Contracts\Session\Session; * 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 { diff --git a/app/Auth/Access/Guards/Saml2SessionGuard.php b/app/Auth/Access/Guards/Saml2SessionGuard.php index 4023913ed..68683bb43 100644 --- a/app/Auth/Access/Guards/Saml2SessionGuard.php +++ b/app/Auth/Access/Guards/Saml2SessionGuard.php @@ -9,8 +9,6 @@ namespace BookStack\Auth\Access\Guards; * 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 { diff --git a/app/Auth/Access/Ldap.php b/app/Auth/Access/Ldap.php index 843a2f204..6b7bd9b9b 100644 --- a/app/Auth/Access/Ldap.php +++ b/app/Auth/Access/Ldap.php @@ -4,7 +4,6 @@ * 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 { diff --git a/app/Auth/SocialAccount.php b/app/Auth/SocialAccount.php index 1c83980cb..116cdc854 100644 --- a/app/Auth/SocialAccount.php +++ b/app/Auth/SocialAccount.php @@ -7,7 +7,6 @@ use BookStack\Model; * Class SocialAccount * @property string $driver * @property User $user - * @package BookStack\Auth */ class SocialAccount extends Model implements Loggable { diff --git a/app/Auth/User.php b/app/Auth/User.php index 5feb269e2..32179a1fb 100644 --- a/app/Auth/User.php +++ b/app/Auth/User.php @@ -18,7 +18,6 @@ use Illuminate\Notifications\Notifiable; /** * Class User - * @package BookStack\Auth * @property string $id * @property string $name * @property string $email diff --git a/app/Entities/BreadcrumbsViewComposer.php b/app/Entities/BreadcrumbsViewComposer.php index 43d63d026..fd0152a7b 100644 --- a/app/Entities/BreadcrumbsViewComposer.php +++ b/app/Entities/BreadcrumbsViewComposer.php @@ -1,6 +1,6 @@ entityContextManager = $entityContextManager; } diff --git a/app/Entities/EntityProvider.php b/app/Entities/EntityProvider.php index d28afe6f2..2246f11f7 100644 --- a/app/Entities/EntityProvider.php +++ b/app/Entities/EntityProvider.php @@ -6,8 +6,6 @@ * 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 { diff --git a/app/Entities/ExportService.php b/app/Entities/ExportService.php index f945dfbe4..c2057481b 100644 --- a/app/Entities/ExportService.php +++ b/app/Entities/ExportService.php @@ -1,7 +1,7 @@ $pages - * @package BookStack\Entities */ class Chapter extends BookChild { diff --git a/app/Entities/Deletion.php b/app/Entities/Models/Deletion.php similarity index 100% rename from app/Entities/Deletion.php rename to app/Entities/Models/Deletion.php diff --git a/app/Entities/Entity.php b/app/Entities/Models/Entity.php similarity index 98% rename from app/Entities/Entity.php rename to app/Entities/Models/Entity.php index 99922bceb..29853fe30 100644 --- a/app/Entities/Entity.php +++ b/app/Entities/Models/Entity.php @@ -32,8 +32,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static Entity|Builder hasPermission(string $permission) * @method static Builder withLastView() * @method static Builder withViewCount() - * - * @package BookStack\Entities */ class Entity extends Ownable { @@ -326,8 +324,7 @@ 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; } } diff --git a/app/Entities/HasCoverImage.php b/app/Entities/Models/HasCoverImage.php similarity index 100% rename from app/Entities/HasCoverImage.php rename to app/Entities/Models/HasCoverImage.php diff --git a/app/Entities/Page.php b/app/Entities/Models/Page.php similarity index 100% rename from app/Entities/Page.php rename to app/Entities/Models/Page.php diff --git a/app/Entities/PageRevision.php b/app/Entities/Models/PageRevision.php similarity index 100% rename from app/Entities/PageRevision.php rename to app/Entities/Models/PageRevision.php diff --git a/app/Entities/SearchTerm.php b/app/Entities/Models/SearchTerm.php similarity index 100% rename from app/Entities/SearchTerm.php rename to app/Entities/Models/SearchTerm.php diff --git a/app/Entities/Repos/BookRepo.php b/app/Entities/Repos/BookRepo.php index f32dd8582..3fb924a89 100644 --- a/app/Entities/Repos/BookRepo.php +++ b/app/Entities/Repos/BookRepo.php @@ -3,7 +3,7 @@ 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; diff --git a/app/Entities/Repos/BookshelfRepo.php b/app/Entities/Repos/BookshelfRepo.php index 039278228..8f12e9dc0 100644 --- a/app/Entities/Repos/BookshelfRepo.php +++ b/app/Entities/Repos/BookshelfRepo.php @@ -3,7 +3,7 @@ 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; diff --git a/app/Entities/Repos/ChapterRepo.php b/app/Entities/Repos/ChapterRepo.php index 312cb69e5..aa9784c2d 100644 --- a/app/Entities/Repos/ChapterRepo.php +++ b/app/Entities/Repos/ChapterRepo.php @@ -3,8 +3,8 @@ 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; diff --git a/app/Entities/Repos/PageRepo.php b/app/Entities/Repos/PageRepo.php index 0e5b48482..7ea79efe6 100644 --- a/app/Entities/Repos/PageRepo.php +++ b/app/Entities/Repos/PageRepo.php @@ -4,9 +4,9 @@ use BookStack\Actions\ActivityType; 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; diff --git a/app/Entities/Managers/BookContents.php b/app/Entities/Tools/BookContents.php similarity index 99% rename from app/Entities/Managers/BookContents.php rename to app/Entities/Tools/BookContents.php index 52447e43b..ae9a95f46 100644 --- a/app/Entities/Managers/BookContents.php +++ b/app/Entities/Tools/BookContents.php @@ -1,4 +1,4 @@ -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; @@ -37,11 +26,10 @@ class EntityContext /** * 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); } /** @@ -49,6 +37,6 @@ class EntityContext */ public function clearShelfContext() { - $this->session->forget($this->KEY_SHELF_CONTEXT_ID); + session()->forget($this->KEY_SHELF_CONTEXT_ID); } } diff --git a/app/Entities/SlugGenerator.php b/app/Entities/Tools/SlugGenerator.php similarity index 54% rename from app/Entities/SlugGenerator.php rename to app/Entities/Tools/SlugGenerator.php index e8bc556ab..884f126e8 100644 --- a/app/Entities/SlugGenerator.php +++ b/app/Entities/Tools/SlugGenerator.php @@ -5,25 +5,14 @@ use Illuminate\Support\Str; 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; @@ -45,16 +34,16 @@ class SlugGenerator * 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; diff --git a/app/Entities/Managers/TrashCan.php b/app/Entities/Tools/TrashCan.php similarity index 99% rename from app/Entities/Managers/TrashCan.php rename to app/Entities/Tools/TrashCan.php index 48768ab93..62d373e97 100644 --- a/app/Entities/Managers/TrashCan.php +++ b/app/Entities/Tools/TrashCan.php @@ -1,4 +1,4 @@ -bookRepo = $bookRepo; $this->entityContextManager = $entityContextManager; diff --git a/app/Http/Controllers/BookSortController.php b/app/Http/Controllers/BookSortController.php index 6d561cfce..7ba11aded 100644 --- a/app/Http/Controllers/BookSortController.php +++ b/app/Http/Controllers/BookSortController.php @@ -4,7 +4,7 @@ namespace BookStack\Http\Controllers; 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; diff --git a/app/Http/Controllers/BookshelfController.php b/app/Http/Controllers/BookshelfController.php index 3001a93f4..52de74b66 100644 --- a/app/Http/Controllers/BookshelfController.php +++ b/app/Http/Controllers/BookshelfController.php @@ -2,7 +2,7 @@ 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; @@ -22,7 +22,7 @@ class BookshelfController extends Controller /** * 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; diff --git a/app/Http/Controllers/ChapterController.php b/app/Http/Controllers/ChapterController.php index e085a0dc7..7fc92a8cf 100644 --- a/app/Http/Controllers/ChapterController.php +++ b/app/Http/Controllers/ChapterController.php @@ -1,7 +1,7 @@ viewService = $viewService; $this->searchService = $searchService; diff --git a/tests/AuditLogTest.php b/tests/AuditLogTest.php index efe842aa1..fa3ee52aa 100644 --- a/tests/AuditLogTest.php +++ b/tests/AuditLogTest.php @@ -4,7 +4,7 @@ use BookStack\Actions\Activity; 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; diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.php index e97df2c7e..6a7b58ffb 100644 --- a/tests/Entity/PageContentTest.php +++ b/tests/Entity/PageContentTest.php @@ -1,6 +1,6 @@