From c87f3abe39ed68f5a74f0d01e30eabb537393b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D?= Date: Tue, 16 Jan 2024 09:19:44 +0100 Subject: [PATCH] chore: Refactor Category naming MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rubén D --- .../api/Controllers/Category/CategoryBase.php | 20 ++++---- .../AccountManager/BulkEditController.php | 20 ++++---- .../Controllers/Category/CategorySaveBase.php | 13 +++--- .../Controllers/Category/CategoryViewBase.php | 8 ++-- .../Controllers/Category/SearchController.php | 14 +++--- .../Helpers/Account/AccountHelper.php | 12 ++--- .../Helpers/Account/AccountHistoryHelper.php | 6 +-- .../Helpers/Account/AccountSearchHelper.php | 26 +++++------ .../ItemManager/IndexController.php | 12 ++--- .../Items/CategoriesController.php | 8 ++-- .../{CategoryAdapter.php => Category.php} | 12 ++--- ...apterInterface.php => CategoryAdapter.php} | 4 +- ...ryInterface.php => CategoryRepository.php} | 4 +- ...rviceInterface.php => CategoryService.php} | 6 +-- lib/SP/Domain/Category/Services/Category.php | 10 ++-- .../Export/Services/XmlExportService.php | 10 ++-- .../Domain/Import/Services/ImportHelper.php | 14 +++--- lib/SP/Domain/Import/Services/ImportTrait.php | 8 ++-- .../{CategoryRepository.php => Category.php} | 42 ++++++++--------- .../Domain/Category/Services/CategoryTest.php | 36 +++++++-------- ...oryRepositoryTest.php => CategoryTest.php} | 46 +++++++++---------- 21 files changed, 166 insertions(+), 165 deletions(-) rename lib/SP/Domain/Category/Adapters/{CategoryAdapter.php => Category.php} (88%) rename lib/SP/Domain/Category/Ports/{CategoryAdapterInterface.php => CategoryAdapter.php} (93%) rename lib/SP/Domain/Category/Ports/{CategoryRepositoryInterface.php => CategoryRepository.php} (95%) rename lib/SP/Domain/Category/Ports/{CategoryServiceInterface.php => CategoryService.php} (94%) rename lib/SP/Infrastructure/Category/Repositories/{CategoryRepository.php => Category.php} (89%) rename tests/SPT/Infrastructure/Category/Repositories/{CategoryRepositoryTest.php => CategoryTest.php} (90%) diff --git a/app/modules/api/Controllers/Category/CategoryBase.php b/app/modules/api/Controllers/Category/CategoryBase.php index 188132ab..5c92b45e 100644 --- a/app/modules/api/Controllers/Category/CategoryBase.php +++ b/app/modules/api/Controllers/Category/CategoryBase.php @@ -28,8 +28,8 @@ namespace SP\Modules\Api\Controllers\Category; use Klein\Klein; use SP\Core\Application; use SP\Domain\Api\Ports\ApiService; -use SP\Domain\Category\Ports\CategoryAdapterInterface; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryAdapter; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Core\Acl\AclInterface; use SP\Domain\Core\Exceptions\InvalidClassException; use SP\Modules\Api\Controllers\ControllerBase; @@ -40,19 +40,19 @@ use SP\Modules\Api\Controllers\Help\CategoryHelp; */ abstract class CategoryBase extends ControllerBase { - protected CategoryServiceInterface $categoryService; - protected CategoryAdapterInterface $categoryAdapter; + protected CategoryService $categoryService; + protected CategoryAdapter $categoryAdapter; /** * @throws InvalidClassException */ public function __construct( - Application $application, - Klein $router, - ApiService $apiService, - AclInterface $acl, - CategoryServiceInterface $categoryService, - CategoryAdapterInterface $categoryAdapter + Application $application, + Klein $router, + ApiService $apiService, + AclInterface $acl, + CategoryService $categoryService, + CategoryAdapter $categoryAdapter ) { parent::__construct($application, $router, $apiService, $acl); diff --git a/app/modules/web/Controllers/AccountManager/BulkEditController.php b/app/modules/web/Controllers/AccountManager/BulkEditController.php index 95819ba9..bc4b090a 100644 --- a/app/modules/web/Controllers/AccountManager/BulkEditController.php +++ b/app/modules/web/Controllers/AccountManager/BulkEditController.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -32,7 +32,7 @@ use SP\Core\Events\Event; use SP\Domain\Account\Ports\AccountHistoryService; use SP\Domain\Account\Ports\AccountSearchService; use SP\Domain\Account\Ports\AccountService; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Core\Acl\AclActionsInterface; use SP\Domain\CustomField\Ports\CustomFieldServiceInterface; @@ -61,20 +61,20 @@ final class BulkEditController extends ControllerBase private AccountSearchService $accountSearchService; private AccountHistoryService $accountHistoryService; private AccountGrid $accountGrid; - private CustomFieldServiceInterface $customFieldService; - private CategoryServiceInterface $categoryService; - private ClientServiceInterface $clientService; + private CustomFieldServiceInterface $customFieldService; + private CategoryService $categoryService; + private ClientServiceInterface $clientService; private TagServiceInterface $tagService; private UserServiceInterface $userService; private UserGroupServiceInterface $userGroupService; public function __construct( - Application $application, - WebControllerHelper $webControllerHelper, - CategoryServiceInterface $categoryService, + Application $application, + WebControllerHelper $webControllerHelper, + CategoryService $categoryService, ClientServiceInterface $clientService, - TagServiceInterface $tagService, - UserServiceInterface $userService, + TagServiceInterface $tagService, + UserServiceInterface $userService, UserGroupServiceInterface $userGroupService ) { parent::__construct($application, $webControllerHelper); diff --git a/app/modules/web/Controllers/Category/CategorySaveBase.php b/app/modules/web/Controllers/Category/CategorySaveBase.php index 6a85eaa9..b3798bc7 100644 --- a/app/modules/web/Controllers/Category/CategorySaveBase.php +++ b/app/modules/web/Controllers/Category/CategorySaveBase.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -25,7 +25,7 @@ namespace SP\Modules\Web\Controllers\Category; use SP\Core\Application; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\CustomField\Ports\CustomFieldServiceInterface; use SP\Modules\Web\Controllers\ControllerBase; use SP\Modules\Web\Controllers\Traits\JsonTrait; @@ -38,16 +38,17 @@ use SP\Mvc\Controller\WebControllerHelper; */ abstract class CategorySaveBase extends ControllerBase { - use JsonTrait, ItemTrait; + use ItemTrait; + use JsonTrait; - protected CategoryServiceInterface $categoryService; + protected CategoryService $categoryService; protected CustomFieldServiceInterface $customFieldService; protected CategoryForm $form; public function __construct( - Application $application, + Application $application, WebControllerHelper $webControllerHelper, - CategoryServiceInterface $categoryService, + CategoryService $categoryService, CustomFieldServiceInterface $customFieldService ) { parent::__construct($application, $webControllerHelper); diff --git a/app/modules/web/Controllers/Category/CategoryViewBase.php b/app/modules/web/Controllers/Category/CategoryViewBase.php index d2be5696..948343d9 100644 --- a/app/modules/web/Controllers/Category/CategoryViewBase.php +++ b/app/modules/web/Controllers/Category/CategoryViewBase.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -27,7 +27,7 @@ namespace SP\Modules\Web\Controllers\Category; use SP\Core\Acl\Acl; use SP\Core\Application; use SP\Domain\Category\Models\Category; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Acl\AclActionsInterface; use SP\Domain\Core\Exceptions\ConstraintException; @@ -46,13 +46,13 @@ abstract class CategoryViewBase extends ControllerBase { use ItemTrait; - private CategoryServiceInterface $categoryService; + private CategoryService $categoryService; private CustomFieldServiceInterface $customFieldService; public function __construct( Application $application, WebControllerHelper $webControllerHelper, - CategoryServiceInterface $categoryService, + CategoryService $categoryService, CustomFieldServiceInterface $customFieldService ) { parent::__construct($application, $webControllerHelper); diff --git a/app/modules/web/Controllers/Category/SearchController.php b/app/modules/web/Controllers/Category/SearchController.php index 230f189c..d9a5b218 100644 --- a/app/modules/web/Controllers/Category/SearchController.php +++ b/app/modules/web/Controllers/Category/SearchController.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -27,7 +27,7 @@ namespace SP\Modules\Web\Controllers\Category; use JsonException; use SP\Core\Application; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Core\Acl\AclActionsInterface; use SP\Domain\Core\Exceptions\ConstraintException; use SP\Domain\Core\Exceptions\QueryException; @@ -48,14 +48,14 @@ final class SearchController extends ControllerBase use ItemTrait; use JsonTrait; - private CategoryServiceInterface $categoryService; - private CategoryGrid $categoryGrid; + private CategoryService $categoryService; + private CategoryGrid $categoryGrid; public function __construct( - Application $application, + Application $application, WebControllerHelper $webControllerHelper, - CategoryServiceInterface $categoryService, - CategoryGrid $categoryGrid + CategoryService $categoryService, + CategoryGrid $categoryGrid ) { parent::__construct($application, $webControllerHelper); diff --git a/app/modules/web/Controllers/Helpers/Account/AccountHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountHelper.php index 151d8ffb..4956bf1d 100644 --- a/app/modules/web/Controllers/Helpers/Account/AccountHelper.php +++ b/app/modules/web/Controllers/Helpers/Account/AccountHelper.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -38,7 +38,7 @@ use SP\Domain\Account\Ports\AccountHistoryService; use SP\Domain\Account\Ports\AccountService; use SP\Domain\Account\Ports\PublicLinkService; use SP\Domain\Account\Services\PublicLink; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Acl\AccountPermissionException; @@ -78,9 +78,9 @@ final class AccountHelper extends AccountHelperBase private PublicLinkService $publicLinkService; private ItemPresetServiceInterface $itemPresetService; private MasterPassServiceInterface $masterPassService; - private AccountAclService $accountAclService; - private CategoryServiceInterface $categoryService; - private ClientServiceInterface $clientService; + private AccountAclService $accountAclService; + private CategoryService $categoryService; + private ClientServiceInterface $clientService; private CustomFieldServiceInterface $customFieldService; private ?AccountPermission $accountAcl = null; private ?int $accountId = null; @@ -100,7 +100,7 @@ final class AccountHelper extends AccountHelperBase MasterPassServiceInterface $masterPassService, AccountActionsHelper $accountActionsHelper, AccountAclService $accountAclService, - CategoryServiceInterface $categoryService, + CategoryService $categoryService, ClientServiceInterface $clientService, CustomFieldServiceInterface $customFieldService, UserServiceInterface $userService, diff --git a/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php index ee813af7..e3b4e503 100644 --- a/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php +++ b/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -32,7 +32,7 @@ use SP\Domain\Account\Ports\AccountAclService; use SP\Domain\Account\Ports\AccountHistoryService; use SP\Domain\Account\Ports\AccountToUserGroupService; use SP\Domain\Account\Ports\AccountToUserService; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Acl\AccountPermissionException; @@ -67,7 +67,7 @@ final class AccountHistoryHelper extends AccountHelperBase MasterPassServiceInterface $masterPassService, private AccountHistoryService $accountHistoryService, private AccountAclService $accountAclService, - private CategoryServiceInterface $categoryService, + private CategoryService $categoryService, private ClientServiceInterface $clientService, private AccountToUserService $accountToUserService, private AccountToUserGroupService $accountToUserGroupService diff --git a/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php index d75d4618..138f18e7 100644 --- a/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php +++ b/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -34,7 +34,7 @@ use SP\Domain\Account\Adapters\AccountSearchItem; use SP\Domain\Account\Dtos\AccountSearchFilterDto; use SP\Domain\Account\Ports\AccountSearchConstants; use SP\Domain\Account\Ports\AccountSearchService; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Core\Acl\AclActionsInterface; use SP\Domain\Core\Exceptions\ConstraintException; @@ -70,19 +70,19 @@ final class AccountSearchHelper extends HelperBase private ?AccountSearchFilterDto $accountSearchFilter = null; private ClientServiceInterface $clientService; private AccountSearchService $accountSearchService; - private AccountActionsHelper $accountActionsHelper; - private CategoryServiceInterface $categoryService; - private TagServiceInterface $tagService; + private AccountActionsHelper $accountActionsHelper; + private CategoryService $categoryService; + private TagServiceInterface $tagService; public function __construct( - Application $application, - TemplateInterface $template, - RequestInterface $request, - ClientServiceInterface $clientService, - CategoryServiceInterface $categoryService, - TagServiceInterface $tagService, - AccountSearchService $accountSearchService, - AccountActionsHelper $accountActionsHelper + Application $application, + TemplateInterface $template, + RequestInterface $request, + ClientServiceInterface $clientService, + CategoryService $categoryService, + TagServiceInterface $tagService, + AccountSearchService $accountSearchService, + AccountActionsHelper $accountActionsHelper ) { parent::__construct($application, $template, $request); diff --git a/app/modules/web/Controllers/ItemManager/IndexController.php b/app/modules/web/Controllers/ItemManager/IndexController.php index 8d426dde..78f46ecf 100644 --- a/app/modules/web/Controllers/ItemManager/IndexController.php +++ b/app/modules/web/Controllers/ItemManager/IndexController.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -31,7 +31,7 @@ use SP\DataModel\ItemSearchData; use SP\Domain\Account\Ports\AccountFileService; use SP\Domain\Account\Ports\AccountHistoryService; use SP\Domain\Account\Ports\AccountService; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Core\Acl\AclActionsInterface; use SP\Domain\Core\Exceptions\ConstraintException; @@ -61,9 +61,9 @@ use SP\Mvc\Controller\WebControllerHelper; final class IndexController extends ControllerBase { protected ?ItemSearchData $itemSearchData = null; - private TabsGridHelper $tabsGridHelper; - private CategoryServiceInterface $categoryService; - private TagServiceInterface $tagService; + private TabsGridHelper $tabsGridHelper; + private CategoryService $categoryService; + private TagServiceInterface $tagService; private ClientServiceInterface $clientService; private CustomFieldDefServiceInterface $customFieldDefService; private AccountFileService $accountFileService; @@ -83,7 +83,7 @@ final class IndexController extends ControllerBase Application $application, WebControllerHelper $webControllerHelper, Helpers\TabsGridHelper $tabsGridHelper, - CategoryServiceInterface $categoryService, + CategoryService $categoryService, TagServiceInterface $tagService, ClientServiceInterface $clientService, CustomFieldDefServiceInterface $customFieldDefService, diff --git a/app/modules/web/Controllers/Items/CategoriesController.php b/app/modules/web/Controllers/Items/CategoriesController.php index 122b370c..ed7043f3 100644 --- a/app/modules/web/Controllers/Items/CategoriesController.php +++ b/app/modules/web/Controllers/Items/CategoriesController.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -25,7 +25,7 @@ namespace SP\Modules\Web\Controllers\Items; use SP\Core\Application; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Core\Exceptions\ConstraintException; use SP\Domain\Core\Exceptions\QueryException; use SP\Domain\Core\Exceptions\SPException; @@ -39,12 +39,12 @@ use SP\Mvc\View\Components\SelectItemAdapter; */ final class CategoriesController extends SimpleControllerBase { - private CategoryServiceInterface $categoryService; + private CategoryService $categoryService; public function __construct( Application $application, SimpleControllerHelper $simpleControllerHelper, - CategoryServiceInterface $categoryService + CategoryService $categoryService ) { parent::__construct($application, $simpleControllerHelper); diff --git a/lib/SP/Domain/Category/Adapters/CategoryAdapter.php b/lib/SP/Domain/Category/Adapters/Category.php similarity index 88% rename from lib/SP/Domain/Category/Adapters/CategoryAdapter.php rename to lib/SP/Domain/Category/Adapters/Category.php index 45f621a6..9839b8b5 100644 --- a/lib/SP/Domain/Category/Adapters/CategoryAdapter.php +++ b/lib/SP/Domain/Category/Adapters/Category.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -25,8 +25,8 @@ namespace SP\Domain\Category\Adapters; use League\Fractal\Resource\Collection; -use SP\Domain\Category\Models\Category; -use SP\Domain\Category\Ports\CategoryAdapterInterface; +use SP\Domain\Category\Models\Category as CategoryModel; +use SP\Domain\Category\Ports\CategoryAdapter; use SP\Domain\Common\Adapters\Adapter; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Config\Ports\ConfigDataInterface; @@ -46,7 +46,7 @@ use SP\Util\Link; * * @package SP\Adapters */ -final class CategoryAdapter extends Adapter implements CategoryAdapterInterface +final class Category extends Adapter implements CategoryAdapter { use ItemTrait; @@ -66,7 +66,7 @@ final class CategoryAdapter extends Adapter implements CategoryAdapterInterface * @throws SPException * @throws ServiceException */ - public function includeCustomFields(Category $data): Collection + public function includeCustomFields(CategoryModel $data): Collection { return $this->collection( $this->getCustomFieldsForItem(AclActionsInterface::CATEGORY, $data->id, $this->customFieldService), @@ -77,7 +77,7 @@ final class CategoryAdapter extends Adapter implements CategoryAdapterInterface /** * @throws ActionNotFoundException */ - public function transform(Category $data): array + public function transform(CategoryModel $data): array { $actionRoute = $this->actions->getActionById(AclActionsInterface::CATEGORY_VIEW)->getRoute(); diff --git a/lib/SP/Domain/Category/Ports/CategoryAdapterInterface.php b/lib/SP/Domain/Category/Ports/CategoryAdapter.php similarity index 93% rename from lib/SP/Domain/Category/Ports/CategoryAdapterInterface.php rename to lib/SP/Domain/Category/Ports/CategoryAdapter.php index e171b3fe..ed05c25f 100644 --- a/lib/SP/Domain/Category/Ports/CategoryAdapterInterface.php +++ b/lib/SP/Domain/Category/Ports/CategoryAdapter.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -36,7 +36,7 @@ use SP\Domain\Core\Exceptions\SPException; * * @package SP\Adapters */ -interface CategoryAdapterInterface +interface CategoryAdapter { /** * @throws ConstraintException diff --git a/lib/SP/Domain/Category/Ports/CategoryRepositoryInterface.php b/lib/SP/Domain/Category/Ports/CategoryRepository.php similarity index 95% rename from lib/SP/Domain/Category/Ports/CategoryRepositoryInterface.php rename to lib/SP/Domain/Category/Ports/CategoryRepository.php index ec7bc6fe..cbd667e8 100644 --- a/lib/SP/Domain/Category/Ports/CategoryRepositoryInterface.php +++ b/lib/SP/Domain/Category/Ports/CategoryRepository.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -38,7 +38,7 @@ use SP\Infrastructure\Database\QueryResult; * * @template T of Category */ -interface CategoryRepositoryInterface extends RepositoryInterface +interface CategoryRepository extends RepositoryInterface { /** * Creates an item diff --git a/lib/SP/Domain/Category/Ports/CategoryServiceInterface.php b/lib/SP/Domain/Category/Ports/CategoryService.php similarity index 94% rename from lib/SP/Domain/Category/Ports/CategoryServiceInterface.php rename to lib/SP/Domain/Category/Ports/CategoryService.php index b4e1ad93..38a1a27e 100644 --- a/lib/SP/Domain/Category/Ports/CategoryServiceInterface.php +++ b/lib/SP/Domain/Category/Ports/CategoryService.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -39,7 +39,7 @@ use SP\Infrastructure\Database\QueryResult; * * @template T of Category */ -interface CategoryServiceInterface +interface CategoryService { /** * @param ItemSearchData $itemSearchData @@ -70,7 +70,7 @@ interface CategoryServiceInterface * @throws QueryException * @throws NoSuchItemException */ - public function delete(int $id): CategoryServiceInterface; + public function delete(int $id): CategoryService; /** * Deletes all the items for given ids diff --git a/lib/SP/Domain/Category/Services/Category.php b/lib/SP/Domain/Category/Services/Category.php index 78c4ce82..09c70d35 100644 --- a/lib/SP/Domain/Category/Services/Category.php +++ b/lib/SP/Domain/Category/Services/Category.php @@ -28,8 +28,8 @@ use Exception; use SP\Core\Application; use SP\DataModel\ItemSearchData; use SP\Domain\Category\Models\Category as CategoryModel; -use SP\Domain\Category\Ports\CategoryRepositoryInterface; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryRepository; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Common\Services\Service; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Exceptions\ConstraintException; @@ -46,11 +46,11 @@ use function SP\__u; * * @template T of CategoryModel */ -final class Category extends Service implements CategoryServiceInterface +final class Category extends Service implements CategoryService { public function __construct( Application $application, - private readonly CategoryRepositoryInterface $categoryRepository + private readonly CategoryRepository $categoryRepository ) { parent::__construct($application); } @@ -106,7 +106,7 @@ final class Category extends Service implements CategoryServiceInterface * @throws QueryException * @throws NoSuchItemException */ - public function delete(int $id): CategoryServiceInterface + public function delete(int $id): CategoryService { if ($this->categoryRepository->delete($id)->getAffectedNumRows() === 0) { throw new NoSuchItemException(__u('Category not found'), SPException::INFO); diff --git a/lib/SP/Domain/Export/Services/XmlExportService.php b/lib/SP/Domain/Export/Services/XmlExportService.php index 9e70c3b8..ac189eb3 100644 --- a/lib/SP/Domain/Export/Services/XmlExportService.php +++ b/lib/SP/Domain/Export/Services/XmlExportService.php @@ -37,7 +37,7 @@ use SP\Core\PhpExtensionChecker; use SP\Domain\Account\Ports\AccountService; use SP\Domain\Account\Ports\AccountToTagService; use SP\Domain\Category\Models\Category; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Common\Services\Service; use SP\Domain\Common\Services\ServiceException; @@ -65,9 +65,9 @@ final class XmlExportService extends Service implements XmlExportServiceInterfac private PhpExtensionChecker $extensionChecker; private ClientServiceInterface $clientService; private AccountService $accountService; - private AccountToTagService $accountToTagService; - private CategoryServiceInterface $categoryService; - private TagServiceInterface $tagService; + private AccountToTagService $accountToTagService; + private CategoryService $categoryService; + private TagServiceInterface $tagService; private ?DOMDocument $xml = null; private ?DOMElement $root = null; private ?string $exportPass = null; @@ -81,7 +81,7 @@ final class XmlExportService extends Service implements XmlExportServiceInterfac ClientServiceInterface $clientService, AccountService $accountService, AccountToTagService $accountToTagService, - CategoryServiceInterface $categoryService, + CategoryService $categoryService, TagServiceInterface $tagService ) { diff --git a/lib/SP/Domain/Import/Services/ImportHelper.php b/lib/SP/Domain/Import/Services/ImportHelper.php index 77688ef7..842bcd39 100644 --- a/lib/SP/Domain/Import/Services/ImportHelper.php +++ b/lib/SP/Domain/Import/Services/ImportHelper.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -26,7 +26,7 @@ namespace SP\Domain\Import\Services; use SP\Domain\Account\Ports\AccountService; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Tag\Ports\TagServiceInterface; @@ -35,14 +35,14 @@ use SP\Domain\Tag\Ports\TagServiceInterface; */ final class ImportHelper { - private AccountService $accountService; - private CategoryServiceInterface $categoryService; - private ClientServiceInterface $clientService; + private AccountService $accountService; + private CategoryService $categoryService; + private ClientServiceInterface $clientService; private TagServiceInterface $tagService; public function __construct( AccountService $accountService, - CategoryServiceInterface $categoryService, + CategoryService $categoryService, ClientServiceInterface $clientService, TagServiceInterface $tagService ) { @@ -57,7 +57,7 @@ final class ImportHelper return $this->accountService; } - public function getCategoryService(): CategoryServiceInterface + public function getCategoryService(): CategoryService { return $this->categoryService; } diff --git a/lib/SP/Domain/Import/Services/ImportTrait.php b/lib/SP/Domain/Import/Services/ImportTrait.php index f5c325bd..8af3efd7 100644 --- a/lib/SP/Domain/Import/Services/ImportTrait.php +++ b/lib/SP/Domain/Import/Services/ImportTrait.php @@ -30,7 +30,7 @@ use SP\DataModel\TagData; use SP\Domain\Account\Dtos\AccountRequest; use SP\Domain\Account\Ports\AccountService; use SP\Domain\Category\Models\Category; -use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Category\Ports\CategoryService; use SP\Domain\Client\Models\Client; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Core\Exceptions\ConstraintException; @@ -54,9 +54,9 @@ trait ImportTrait protected bool $mPassValidHash = false; protected int $counter = 0; protected ImportParams $importParams; - private AccountService $accountService; - private CategoryServiceInterface $categoryService; - private ClientServiceInterface $clientService; + private AccountService $accountService; + private CategoryService $categoryService; + private ClientServiceInterface $clientService; private TagServiceInterface $tagService; private array $items; diff --git a/lib/SP/Infrastructure/Category/Repositories/CategoryRepository.php b/lib/SP/Infrastructure/Category/Repositories/Category.php similarity index 89% rename from lib/SP/Infrastructure/Category/Repositories/CategoryRepository.php rename to lib/SP/Infrastructure/Category/Repositories/Category.php index da2f61a7..4c7e1cdc 100644 --- a/lib/SP/Infrastructure/Category/Repositories/CategoryRepository.php +++ b/lib/SP/Infrastructure/Category/Repositories/Category.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -26,8 +26,8 @@ namespace SP\Infrastructure\Category\Repositories; use Exception; use SP\DataModel\ItemSearchData; -use SP\Domain\Category\Models\Category; -use SP\Domain\Category\Ports\CategoryRepositoryInterface; +use SP\Domain\Category\Models\Category as CategoryModel; +use SP\Domain\Category\Ports\CategoryRepository; use SP\Domain\Core\Exceptions\ConstraintException; use SP\Domain\Core\Exceptions\QueryException; use SP\Infrastructure\Common\Repositories\DuplicatedItemException; @@ -41,9 +41,9 @@ use function SP\__u; /** * Class CategoryRepository * - * @template T of Category + * @template T of CategoryModel */ -final class CategoryRepository extends Repository implements CategoryRepositoryInterface +final class Category extends Repository implements CategoryRepository { use RepositoryItemTrait; @@ -52,14 +52,14 @@ final class CategoryRepository extends Repository implements CategoryRepositoryI /** * Creates an item * - * @param Category $category + * @param CategoryModel $category * * @return QueryResult * @throws ConstraintException * @throws DuplicatedItemException * @throws QueryException */ - public function create(Category $category): QueryResult + public function create(CategoryModel $category): QueryResult { if ($this->checkDuplicatedOnAdd($category)) { throw new DuplicatedItemException(__u('Duplicated category')); @@ -79,13 +79,13 @@ final class CategoryRepository extends Repository implements CategoryRepositoryI /** * Checks whether the item is duplicated on adding * - * @param Category $category + * @param CategoryModel $category * * @return bool * @throws ConstraintException * @throws QueryException */ - private function checkDuplicatedOnAdd(Category $category): bool + private function checkDuplicatedOnAdd(CategoryModel $category): bool { $query = $this->queryFactory ->newSelect() @@ -106,14 +106,14 @@ final class CategoryRepository extends Repository implements CategoryRepositoryI /** * Updates an item * - * @param Category $category + * @param CategoryModel $category * * @return int * @throws DuplicatedItemException * @throws ConstraintException * @throws QueryException */ - public function update(Category $category): int + public function update(CategoryModel $category): int { if ($this->checkDuplicatedOnUpdate($category)) { throw new DuplicatedItemException(__u('Duplicated category name')); @@ -140,13 +140,13 @@ final class CategoryRepository extends Repository implements CategoryRepositoryI /** * Checks whether the item is duplicated on updating * - * @param Category $category + * @param CategoryModel $category * * @return bool * @throws ConstraintException * @throws QueryException */ - private function checkDuplicatedOnUpdate(Category $category): bool + private function checkDuplicatedOnUpdate(CategoryModel $category): bool { $query = $this->queryFactory ->newSelect() @@ -177,12 +177,12 @@ final class CategoryRepository extends Repository implements CategoryRepositoryI $query = $this->queryFactory ->newSelect() ->from(self::TABLE) - ->cols(Category::getCols()) + ->cols(CategoryModel::getCols()) ->where('id = :id') ->bindValues(['id' => $categoryId]) ->limit(1); - $queryData = QueryData::buildWithMapper($query, Category::class); + $queryData = QueryData::buildWithMapper($query, CategoryModel::class); return $this->db->doSelect($queryData); } @@ -199,12 +199,12 @@ final class CategoryRepository extends Repository implements CategoryRepositoryI $query = $this->queryFactory ->newSelect() ->from(self::TABLE) - ->cols(Category::getCols()) + ->cols(CategoryModel::getCols()) ->where('(name = :name OR hash = :hash)') ->bindValues(['name' => $name, 'hash' => $this->makeItemHash($name)]) ->limit(1); - $queryData = QueryData::buildWithMapper($query, Category::class); + $queryData = QueryData::buildWithMapper($query, CategoryModel::class); return $this->db->doSelect($queryData); } @@ -219,9 +219,9 @@ final class CategoryRepository extends Repository implements CategoryRepositoryI $query = $this->queryFactory ->newSelect() ->from(self::TABLE) - ->cols(Category::getCols()); + ->cols(CategoryModel::getCols()); - return $this->db->doSelect(QueryData::buildWithMapper($query, Category::class)); + return $this->db->doSelect(QueryData::buildWithMapper($query, CategoryModel::class)); } /** @@ -284,7 +284,7 @@ final class CategoryRepository extends Repository implements CategoryRepositoryI $query = $this->queryFactory ->newSelect() ->from(self::TABLE) - ->cols(Category::getCols(['hash'])) + ->cols(CategoryModel::getCols(['hash'])) ->orderBy(['name']) ->limit($itemSearchData->getLimitCount()) ->offset($itemSearchData->getLimitStart()); @@ -297,7 +297,7 @@ final class CategoryRepository extends Repository implements CategoryRepositoryI $query->bindValues(['name' => $search, 'description' => $search]); } - $queryData = QueryData::build($query)->setMapClassName(Category::class); + $queryData = QueryData::build($query)->setMapClassName(CategoryModel::class); return $this->db->doSelect($queryData, true); } diff --git a/tests/SPT/Domain/Category/Services/CategoryTest.php b/tests/SPT/Domain/Category/Services/CategoryTest.php index d1eac2c7..6797d4d2 100644 --- a/tests/SPT/Domain/Category/Services/CategoryTest.php +++ b/tests/SPT/Domain/Category/Services/CategoryTest.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -26,7 +26,7 @@ namespace SPT\Domain\Category\Services; use Exception; use PHPUnit\Framework\MockObject\MockObject; -use SP\Domain\Category\Ports\CategoryRepositoryInterface; +use SP\Domain\Category\Ports\CategoryRepository; use SP\Domain\Category\Services\Category; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Exceptions\ConstraintException; @@ -47,8 +47,8 @@ use SPT\UnitaryTestCase; class CategoryTest extends UnitaryTestCase { - private CategoryRepositoryInterface|MockObject $categoryRepository; - private Category $categoryService; + private CategoryRepository|MockObject $categoryRepository; + private Category $category; /** * @throws NoSuchItemException @@ -68,7 +68,7 @@ class CategoryTest extends UnitaryTestCase ->with($id) ->willReturn(new QueryResult([$category])); - $out = $this->categoryService->getById($id); + $out = $this->category->getById($id); $this->assertEquals($category, $out); } @@ -94,7 +94,7 @@ class CategoryTest extends UnitaryTestCase $this->expectException(NoSuchItemException::class); $this->expectExceptionMessage('Category not found'); - $this->categoryService->getById($id); + $this->category->getById($id); } /** @@ -109,7 +109,7 @@ class CategoryTest extends UnitaryTestCase ->method('search') ->with($itemSearch); - $this->categoryService->search($itemSearch); + $this->category->search($itemSearch); } /** @@ -130,7 +130,7 @@ class CategoryTest extends UnitaryTestCase ->with($id) ->willReturn($queryResult); - $this->categoryService->delete($id); + $this->category->delete($id); } /** @@ -150,7 +150,7 @@ class CategoryTest extends UnitaryTestCase $this->expectException(NoSuchItemException::class); $this->expectExceptionMessage('Category not found'); - $this->categoryService->delete($id); + $this->category->delete($id); } /** @@ -170,7 +170,7 @@ class CategoryTest extends UnitaryTestCase ->with($category) ->willReturn($queryResult); - $out = $this->categoryService->create($category); + $out = $this->category->create($category); $this->assertEquals($queryResult->getLastId(), $out); } @@ -193,7 +193,7 @@ class CategoryTest extends UnitaryTestCase ->with($category) ->willReturn(1); - $this->categoryService->update($category); + $this->category->update($category); } /** @@ -214,7 +214,7 @@ class CategoryTest extends UnitaryTestCase ->with($name) ->willReturn(new QueryResult([$category])); - $out = $this->categoryService->getByName($name); + $out = $this->category->getByName($name); $this->assertEquals($category, $out); } @@ -238,7 +238,7 @@ class CategoryTest extends UnitaryTestCase $this->expectException(NoSuchItemException::class); $this->expectExceptionMessage('Category not found'); - $this->categoryService->getByName($name); + $this->category->getByName($name); } /** @@ -259,7 +259,7 @@ class CategoryTest extends UnitaryTestCase ->with($ids) ->willReturn($queryResult); - $this->categoryService->deleteByIdBatch($ids); + $this->category->deleteByIdBatch($ids); } /** @@ -282,7 +282,7 @@ class CategoryTest extends UnitaryTestCase $this->expectException(ServiceException::class); $this->expectExceptionMessage('Error while deleting categories'); - $this->categoryService->deleteByIdBatch($ids); + $this->category->deleteByIdBatch($ids); } /** @@ -299,7 +299,7 @@ class CategoryTest extends UnitaryTestCase ->method('getAll') ->willReturn(new QueryResult([$category])); - $out = $this->categoryService->getAll(); + $out = $this->category->getAll(); $this->assertEquals([$category], $out); } @@ -308,7 +308,7 @@ class CategoryTest extends UnitaryTestCase { parent::setUp(); - $this->categoryRepository = $this->createMock(CategoryRepositoryInterface::class); - $this->categoryService = new Category($this->application, $this->categoryRepository); + $this->categoryRepository = $this->createMock(CategoryRepository::class); + $this->category = new Category($this->application, $this->categoryRepository); } } diff --git a/tests/SPT/Infrastructure/Category/Repositories/CategoryRepositoryTest.php b/tests/SPT/Infrastructure/Category/Repositories/CategoryTest.php similarity index 90% rename from tests/SPT/Infrastructure/Category/Repositories/CategoryRepositoryTest.php rename to tests/SPT/Infrastructure/Category/Repositories/CategoryTest.php index d6ec963e..df421372 100644 --- a/tests/SPT/Infrastructure/Category/Repositories/CategoryRepositoryTest.php +++ b/tests/SPT/Infrastructure/Category/Repositories/CategoryTest.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -33,11 +33,11 @@ use Exception; use PHPUnit\Framework\Constraint\Callback; use PHPUnit\Framework\MockObject\MockObject; use SP\DataModel\ItemSearchData; -use SP\Domain\Category\Models\Category; +use SP\Domain\Category\Models\Category as CategoryModel; use SP\Domain\Common\Models\Simple; use SP\Domain\Core\Exceptions\ConstraintException; use SP\Domain\Core\Exceptions\QueryException; -use SP\Infrastructure\Category\Repositories\CategoryRepository; +use SP\Infrastructure\Category\Repositories\Category; use SP\Infrastructure\Common\Repositories\DuplicatedItemException; use SP\Infrastructure\Database\DatabaseInterface; use SP\Infrastructure\Database\QueryData; @@ -50,10 +50,10 @@ use SPT\UnitaryTestCase; * * @group unitary */ -class CategoryRepositoryTest extends UnitaryTestCase +class CategoryTest extends UnitaryTestCase { - private CategoryRepository $categoryRepository; + private Category $category; private DatabaseInterface|MockObject $database; /** @@ -98,7 +98,7 @@ class CategoryRepositoryTest extends UnitaryTestCase ->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate])) ->willReturn(new QueryResult([]), new QueryResult([1])); - $this->categoryRepository->create($category); + $this->category->create($category); } /** @@ -132,7 +132,7 @@ class CategoryRepositoryTest extends UnitaryTestCase $this->expectException(DuplicatedItemException::class); $this->expectExceptionMessage('Duplicated category'); - $this->categoryRepository->create($category); + $this->category->create($category); } /** @@ -155,7 +155,7 @@ class CategoryRepositoryTest extends UnitaryTestCase $this->database->expects(self::once())->method('doQuery')->with($callback); - $this->categoryRepository->delete($id); + $this->category->delete($id); } /** @@ -186,7 +186,7 @@ class CategoryRepositoryTest extends UnitaryTestCase ->method('doQuery') ->with($callback); - $this->categoryRepository->deleteByIdBatch($ids); + $this->category->deleteByIdBatch($ids); } /** @@ -199,7 +199,7 @@ class CategoryRepositoryTest extends UnitaryTestCase ->expects(self::never()) ->method('doQuery'); - $this->categoryRepository->deleteByIdBatch([]); + $this->category->deleteByIdBatch([]); } public function testGetById() @@ -213,7 +213,7 @@ class CategoryRepositoryTest extends UnitaryTestCase return count($params) === 1 && $params['id'] === $id - && $arg->getMapClassName() === Category::class + && $arg->getMapClassName() === CategoryModel::class && is_a($query, SelectInterface::class) && !empty($query->getStatement()); } @@ -224,7 +224,7 @@ class CategoryRepositoryTest extends UnitaryTestCase ->method('doSelect') ->with($callback); - $this->categoryRepository->getById($id); + $this->category->getById($id); } /** @@ -243,7 +243,7 @@ class CategoryRepositoryTest extends UnitaryTestCase return count($params) === 2 && $params['name'] === $searchStringLike && $params['description'] === $searchStringLike - && $arg->getMapClassName() === Category::class + && $arg->getMapClassName() === CategoryModel::class && is_a($query, SelectInterface::class) && !empty($query->getStatement()); } @@ -254,7 +254,7 @@ class CategoryRepositoryTest extends UnitaryTestCase ->method('doSelect') ->with($callback, true); - $this->categoryRepository->search($item); + $this->category->search($item); } /** @@ -266,7 +266,7 @@ class CategoryRepositoryTest extends UnitaryTestCase static function (QueryData $arg) { $query = $arg->getQuery(); return count($query->getBindValues()) === 0 - && $arg->getMapClassName() === Category::class + && $arg->getMapClassName() === CategoryModel::class && is_a($query, SelectInterface::class) && !empty($query->getStatement()); } @@ -277,7 +277,7 @@ class CategoryRepositoryTest extends UnitaryTestCase ->method('doSelect') ->with($callback, true); - $this->categoryRepository->search(new ItemSearchData()); + $this->category->search(new ItemSearchData()); } public function testGetAll() @@ -285,7 +285,7 @@ class CategoryRepositoryTest extends UnitaryTestCase $callback = new Callback( static function (QueryData $arg) { $query = $arg->getQuery(); - return $arg->getMapClassName() === Category::class + return $arg->getMapClassName() === CategoryModel::class && is_a($query, SelectInterface::class) && !empty($query->getStatement()); } @@ -296,7 +296,7 @@ class CategoryRepositoryTest extends UnitaryTestCase ->method('doSelect') ->with($callback); - $this->categoryRepository->getAll(); + $this->category->getAll(); } /** @@ -343,7 +343,7 @@ class CategoryRepositoryTest extends UnitaryTestCase ->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate])) ->willReturn(new QueryResult([]), new QueryResult([1])); - $this->categoryRepository->update($category); + $this->category->update($category); } /** @@ -377,7 +377,7 @@ class CategoryRepositoryTest extends UnitaryTestCase $this->expectException(DuplicatedItemException::class); $this->expectExceptionMessage('Duplicated category name'); - $this->categoryRepository->update($category); + $this->category->update($category); } public function testGetByName() @@ -392,7 +392,7 @@ class CategoryRepositoryTest extends UnitaryTestCase return count($params) === 2 && $params['name'] === $name && !empty($params['hash']) - && $arg->getMapClassName() === Category::class + && $arg->getMapClassName() === CategoryModel::class && is_a($query, SelectInterface::class) && !empty($query->getStatement()); } @@ -403,7 +403,7 @@ class CategoryRepositoryTest extends UnitaryTestCase ->method('doSelect') ->with($callback); - $this->categoryRepository->getByName($name); + $this->category->getByName($name); } protected function setUp(): void @@ -413,7 +413,7 @@ class CategoryRepositoryTest extends UnitaryTestCase $this->database = $this->createMock(DatabaseInterface::class); $queryFactory = new QueryFactory('mysql'); - $this->categoryRepository = new CategoryRepository( + $this->category = new Category( $this->database, $this->context, $this->application->getEventDispatcher(),