diff --git a/app/modules/api/Controllers/Client/CreateController.php b/app/modules/api/Controllers/Client/CreateController.php index a139cd0a..1513fd19 100644 --- a/app/modules/api/Controllers/Client/CreateController.php +++ b/app/modules/api/Controllers/Client/CreateController.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. * @@ -28,8 +28,8 @@ namespace SP\Modules\Api\Controllers\Client; use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; -use SP\DataModel\ClientData; use SP\Domain\Api\Services\ApiResponse; +use SP\Domain\Client\Models\Client; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Acl\AclActionsInterface; @@ -72,12 +72,12 @@ final class CreateController extends ClientBase } /** - * @return ClientData + * @return Client * @throws ServiceException */ - private function buildClientData(): ClientData + private function buildClientData(): Client { - $clientData = new ClientData(); + $clientData = new Client(); $clientData->setName($this->apiService->getParamString('name', true)); $clientData->setDescription($this->apiService->getParamString('description')); $clientData->setIsGlobal($this->apiService->getParamInt('global')); diff --git a/app/modules/api/Controllers/Client/EditController.php b/app/modules/api/Controllers/Client/EditController.php index 21321d55..274fdb9a 100644 --- a/app/modules/api/Controllers/Client/EditController.php +++ b/app/modules/api/Controllers/Client/EditController.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. * @@ -28,8 +28,8 @@ namespace SP\Modules\Api\Controllers\Client; use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; -use SP\DataModel\ClientData; use SP\Domain\Api\Services\ApiResponse; +use SP\Domain\Client\Models\Client; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Acl\AclActionsInterface; @@ -70,12 +70,12 @@ final class EditController extends ClientBase } /** - * @return ClientData + * @return Client * @throws ServiceException */ - private function buildClientData(): ClientData + private function buildClientData(): Client { - $clientData = new ClientData(); + $clientData = new Client(); $clientData->setId($this->apiService->getParamInt('id', true)); $clientData->setName($this->apiService->getParamString('name', true)); $clientData->setDescription($this->apiService->getParamString('description')); diff --git a/app/modules/web/Controllers/Client/ClientViewBase.php b/app/modules/web/Controllers/Client/ClientViewBase.php index dca69abb..4b7ca533 100644 --- a/app/modules/web/Controllers/Client/ClientViewBase.php +++ b/app/modules/web/Controllers/Client/ClientViewBase.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\Client; use SP\Core\Acl\Acl; use SP\Core\Application; -use SP\DataModel\ClientData; +use SP\Domain\Client\Models\Client; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Acl\AclActionsInterface; @@ -81,7 +81,7 @@ abstract class ClientViewBase extends ControllerBase $client = $clientId ? $this->clientService->getById($clientId) - : new ClientData(); + : new Client(); $this->view->assign('client', $client); diff --git a/app/modules/web/Forms/ClientForm.php b/app/modules/web/Forms/ClientForm.php index 70695350..21f9124a 100644 --- a/app/modules/web/Forms/ClientForm.php +++ b/app/modules/web/Forms/ClientForm.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. * @@ -24,7 +24,7 @@ namespace SP\Modules\Web\Forms; -use SP\DataModel\ClientData; +use SP\Domain\Client\Models\Client; use SP\Domain\Core\Acl\AclActionsInterface; use SP\Domain\Core\Exceptions\ValidationException; @@ -35,13 +35,13 @@ use SP\Domain\Core\Exceptions\ValidationException; */ final class ClientForm extends FormBase implements FormInterface { - protected ?ClientData $clientData = null; + protected ?Client $clientData = null; /** * Validar el formulario * - * @param int $action - * @param int|null $id + * @param int $action + * @param int|null $id * * @return ClientForm|FormInterface * @throws ValidationException @@ -70,11 +70,15 @@ final class ClientForm extends FormBase implements FormInterface */ protected function analyzeRequestData(): void { - $this->clientData = new ClientData(); - $this->clientData->setId($this->itemId); - $this->clientData->setName($this->request->analyzeString('name')); - $this->clientData->setDescription($this->request->analyzeString('description')); - $this->clientData->setIsGlobal($this->request->analyzeBool('isglobal', false)); + $this->clientData = new Client( + [ + 'id' => $this->itemId, + 'name' => $this->request->analyzeString('name'), + 'description' => $this->request->analyzeString('description'), + 'isglobal' => $this->request->analyzeBool('isglobal', false) + + ] + ); } /** @@ -87,7 +91,7 @@ final class ClientForm extends FormBase implements FormInterface } } - public function getItemData(): ?ClientData + public function getItemData(): ?Client { return $this->clientData; } diff --git a/app/modules/web/themes/material-blue/views/itemshow/client.inc b/app/modules/web/themes/material-blue/views/itemshow/client.inc index 610204ee..1120b431 100644 --- a/app/modules/web/themes/material-blue/views/itemshow/client.inc +++ b/app/modules/web/themes/material-blue/views/itemshow/client.inc @@ -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. * @@ -23,14 +23,14 @@ */ /** - * @var ClientData $client - * @var \SP\Domain\Core\UI\ThemeIconsInterface $icons + * @var \SP\Domain\Client\Models\Client $client + * @var ThemeIconsInterface $icons * @var ConfigDataInterface $configData * @var callable $_getvar * @var TemplateInterface $this */ -use SP\DataModel\ClientData; +use SP\Domain\Client\Models\Client; use SP\Domain\Config\Ports\ConfigDataInterface; use SP\Domain\Core\UI\ThemeIconsInterface; use SP\Mvc\View\TemplateInterface; diff --git a/composer.lock b/composer.lock index 0d5cefbd..57197aa2 100644 --- a/composer.lock +++ b/composer.lock @@ -2004,16 +2004,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "2.0.45", + "version": "2.0.46", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "28d8f438a0064c9de80857e3270d071495544640" + "reference": "498e67a0c82bd5791fda9b0dd0f4ec8e8aebb02d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/28d8f438a0064c9de80857e3270d071495544640", - "reference": "28d8f438a0064c9de80857e3270d071495544640", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/498e67a0c82bd5791fda9b0dd0f4ec8e8aebb02d", + "reference": "498e67a0c82bd5791fda9b0dd0f4ec8e8aebb02d", "shasum": "" }, "require": { @@ -2094,7 +2094,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/2.0.45" + "source": "https://github.com/phpseclib/phpseclib/tree/2.0.46" }, "funding": [ { @@ -2110,7 +2110,7 @@ "type": "tidelift" } ], - "time": "2023-09-15T20:55:47+00:00" + "time": "2023-12-29T01:52:43+00:00" }, { "name": "psr/cache", @@ -2363,16 +2363,16 @@ }, { "name": "symfony/console", - "version": "v5.4.32", + "version": "v5.4.34", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c70df1ffaf23a8d340bded3cfab1b86752ad6ed7" + "reference": "4b4d8cd118484aa604ec519062113dd87abde18c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c70df1ffaf23a8d340bded3cfab1b86752ad6ed7", - "reference": "c70df1ffaf23a8d340bded3cfab1b86752ad6ed7", + "url": "https://api.github.com/repos/symfony/console/zipball/4b4d8cd118484aa604ec519062113dd87abde18c", + "reference": "4b4d8cd118484aa604ec519062113dd87abde18c", "shasum": "" }, "require": { @@ -2442,7 +2442,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.32" + "source": "https://github.com/symfony/console/tree/v5.4.34" }, "funding": [ { @@ -2458,7 +2458,7 @@ "type": "tidelift" } ], - "time": "2023-11-18T18:23:04+00:00" + "time": "2023-12-08T13:33:03+00:00" }, { "name": "symfony/deprecation-contracts", @@ -2529,16 +2529,16 @@ }, { "name": "symfony/lock", - "version": "v5.4.32", + "version": "v5.4.34", "source": { "type": "git", "url": "https://github.com/symfony/lock.git", - "reference": "a6d7d829f4907134775a0e1b162780e61f80ed87" + "reference": "26ff165e2b501ff7ead2f30a02f7e0eb0975866e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/lock/zipball/a6d7d829f4907134775a0e1b162780e61f80ed87", - "reference": "a6d7d829f4907134775a0e1b162780e61f80ed87", + "url": "https://api.github.com/repos/symfony/lock/zipball/26ff165e2b501ff7ead2f30a02f7e0eb0975866e", + "reference": "26ff165e2b501ff7ead2f30a02f7e0eb0975866e", "shasum": "" }, "require": { @@ -2588,7 +2588,7 @@ "semaphore" ], "support": { - "source": "https://github.com/symfony/lock/tree/v5.4.32" + "source": "https://github.com/symfony/lock/tree/v5.4.34" }, "funding": [ { @@ -2604,7 +2604,7 @@ "type": "tidelift" } ], - "time": "2023-11-20T15:40:25+00:00" + "time": "2023-12-18T14:56:06+00:00" }, { "name": "symfony/polyfill-ctype", @@ -3263,21 +3263,21 @@ }, { "name": "symfony/service-contracts", - "version": "v3.4.0", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838" + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/b3313c2dbffaf71c8de2934e2ea56ed2291a3838", - "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/fe07cbc8d837f60caf7018068e350cc5163681a0", + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^2.0" + "psr/container": "^1.1|^2.0" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -3325,7 +3325,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.4.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.4.1" }, "funding": [ { @@ -3341,20 +3341,20 @@ "type": "tidelift" } ], - "time": "2023-07-30T20:28:31+00:00" + "time": "2023-12-26T14:02:43+00:00" }, { "name": "symfony/string", - "version": "v6.4.0", + "version": "v6.4.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "b45fcf399ea9c3af543a92edf7172ba21174d809" + "reference": "7cb80bc10bfcdf6b5492741c0b9357dac66940bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/b45fcf399ea9c3af543a92edf7172ba21174d809", - "reference": "b45fcf399ea9c3af543a92edf7172ba21174d809", + "url": "https://api.github.com/repos/symfony/string/zipball/7cb80bc10bfcdf6b5492741c0b9357dac66940bc", + "reference": "7cb80bc10bfcdf6b5492741c0b9357dac66940bc", "shasum": "" }, "require": { @@ -3411,7 +3411,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.0" + "source": "https://github.com/symfony/string/tree/v6.4.2" }, "funding": [ { @@ -3427,7 +3427,7 @@ "type": "tidelift" } ], - "time": "2023-11-28T20:41:49+00:00" + "time": "2023-12-10T16:15:48+00:00" }, { "name": "vlucas/phpdotenv", @@ -3575,16 +3575,16 @@ }, { "name": "fakerphp/faker", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/FakerPHP/Faker.git", - "reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01" + "reference": "bfb4fe148adbf78eff521199619b93a52ae3554b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e3daa170d00fde61ea7719ef47bb09bb8f1d9b01", - "reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/bfb4fe148adbf78eff521199619b93a52ae3554b", + "reference": "bfb4fe148adbf78eff521199619b93a52ae3554b", "shasum": "" }, "require": { @@ -3610,11 +3610,6 @@ "ext-mbstring": "Required for multibyte Unicode string functionality." }, "type": "library", - "extra": { - "branch-alias": { - "dev-main": "v1.21-dev" - } - }, "autoload": { "psr-4": { "Faker\\": "src/Faker/" @@ -3637,9 +3632,9 @@ ], "support": { "issues": "https://github.com/FakerPHP/Faker/issues", - "source": "https://github.com/FakerPHP/Faker/tree/v1.23.0" + "source": "https://github.com/FakerPHP/Faker/tree/v1.23.1" }, - "time": "2023-06-12T08:44:38+00:00" + "time": "2024-01-02T13:46:09+00:00" }, { "name": "myclabs/deep-copy", @@ -3702,16 +3697,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.17.1", + "version": "v4.18.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" + "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", "shasum": "" }, "require": { @@ -3752,9 +3747,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" }, - "time": "2023-08-13T19:53:39+00:00" + "time": "2023-12-10T21:03:43+00:00" }, { "name": "phar-io/manifest", @@ -3869,16 +3864,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.47", + "version": "1.10.55", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "84dbb33b520ea28b6cf5676a3941f4bae1c1ff39" + "reference": "9a88f9d18ddf4cf54c922fbeac16c4cb164c5949" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/84dbb33b520ea28b6cf5676a3941f4bae1c1ff39", - "reference": "84dbb33b520ea28b6cf5676a3941f4bae1c1ff39", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9a88f9d18ddf4cf54c922fbeac16c4cb164c5949", + "reference": "9a88f9d18ddf4cf54c922fbeac16c4cb164c5949", "shasum": "" }, "require": { @@ -3927,27 +3922,27 @@ "type": "tidelift" } ], - "time": "2023-12-01T15:19:17+00:00" + "time": "2024-01-08T12:32:40+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.1.9", + "version": "10.1.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "a56a9ab2f680246adcf3db43f38ddf1765774735" + "reference": "78c3b7625965c2513ee96569a4dbb62601784145" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/a56a9ab2f680246adcf3db43f38ddf1765774735", - "reference": "a56a9ab2f680246adcf3db43f38ddf1765774735", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/78c3b7625965c2513ee96569a4dbb62601784145", + "reference": "78c3b7625965c2513ee96569a4dbb62601784145", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1", "phpunit/php-file-iterator": "^4.0", "phpunit/php-text-template": "^3.0", @@ -3997,7 +3992,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.9" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.11" }, "funding": [ { @@ -4005,7 +4000,7 @@ "type": "github" } ], - "time": "2023-11-23T12:23:20+00:00" + "time": "2023-12-21T15:38:30+00:00" }, { "name": "phpunit/php-file-iterator", @@ -4252,16 +4247,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.2", + "version": "10.5.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "5aedff46afba98dddecaa12349ec044d9103d4fe" + "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5aedff46afba98dddecaa12349ec044d9103d4fe", - "reference": "5aedff46afba98dddecaa12349ec044d9103d4fe", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed21115d505b4b4f7dc7b5651464e19a2c7f7856", + "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856", "shasum": "" }, "require": { @@ -4333,7 +4328,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.2" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.5" }, "funding": [ { @@ -4349,7 +4344,7 @@ "type": "tidelift" } ], - "time": "2023-12-05T14:54:33+00:00" + "time": "2023-12-27T15:13:52+00:00" }, { "name": "roave/security-advisories", @@ -4357,12 +4352,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "498a07ca22004364fc54bc909b77de792a10c127" + "reference": "3aeeaaaaf57836ed6184047f88f744db41e8922d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/498a07ca22004364fc54bc909b77de792a10c127", - "reference": "498a07ca22004364fc54bc909b77de792a10c127", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/3aeeaaaaf57836ed6184047f88f744db41e8922d", + "reference": "3aeeaaaaf57836ed6184047f88f744db41e8922d", "shasum": "" }, "conflict": { @@ -4394,9 +4389,9 @@ "athlon1600/php-proxy": "<=5.1", "athlon1600/php-proxy-app": "<=3", "austintoddj/canvas": "<=3.4.2", - "automad/automad": "<1.8", + "automad/automad": "<=1.10.9", "awesome-support/awesome-support": "<=6.0.7", - "aws/aws-sdk-php": ">=3,<3.2.1", + "aws/aws-sdk-php": "<3.288.1", "azuracast/azuracast": "<0.18.3", "backdrop/backdrop": "<1.24.2", "backpack/crud": "<3.4.9", @@ -4436,6 +4431,7 @@ "cesnet/simplesamlphp-module-proxystatistics": "<3.1", "chriskacerguis/codeigniter-restserver": "<=2.7.1", "civicrm/civicrm-core": ">=4.2,<4.2.9|>=4.3,<4.3.3", + "ckeditor/ckeditor": "<4.17", "cockpit-hq/cockpit": "<=2.6.3", "codeception/codeception": "<3.1.3|>=4,<4.1.22", "codeigniter/framework": "<3.1.9", @@ -4443,7 +4439,7 @@ "codeigniter4/shield": "<1.0.0.0-beta8", "codiad/codiad": "<=2.8.4", "composer/composer": "<1.10.27|>=2,<2.2.22|>=2.3,<2.6.4", - "concrete5/concrete5": "<9.2.2", + "concrete5/concrete5": "<9.2.3", "concrete5/core": "<8.5.8|>=9,<9.1", "contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao/contao": ">=4,<4.4.56|>=4.5,<4.9.40|>=4.10,<4.11.7|>=4.13,<4.13.21|>=5.1,<5.1.4", @@ -4451,8 +4447,9 @@ "contao/core-bundle": "<4.9.42|>=4.10,<4.13.28|>=5,<5.1.10", "contao/listing-bundle": ">=4,<4.4.8", "contao/managed-edition": "<=1.5", + "corveda/phpsandbox": "<1.3.5", "cosenary/instagram": "<=2.3", - "craftcms/cms": "<=4.4.14", + "craftcms/cms": "<=4.5.10", "croogo/croogo": "<4", "cuyz/valinor": "<0.12", "czproject/git-php": "<4.0.3", @@ -4465,7 +4462,7 @@ "derhansen/fe_change_pwd": "<2.0.5|>=3,<3.0.3", "derhansen/sf_event_mgt": "<4.3.1|>=5,<5.1.1", "desperado/xml-bundle": "<=0.1.7", - "directmailteam/direct-mail": "<5.2.4", + "directmailteam/direct-mail": "<6.0.3|>=7,<7.0.3|>=8,<9.5.2", "doctrine/annotations": "<1.2.7", "doctrine/cache": "<1.3.2|>=1.4,<1.4.2", "doctrine/common": "<2.4.3|>=2.5,<2.5.1", @@ -4476,9 +4473,9 @@ "doctrine/mongodb-odm-bundle": "<3.0.1", "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1|>=2.8.3,<2.8.4", "dolibarr/dolibarr": "<18.0.2", - "dompdf/dompdf": "<2.0.2|==2.0.2", + "dompdf/dompdf": "<2.0.4", "doublethreedigital/guest-entries": "<3.1.2", - "drupal/core": "<9.4.14|>=9.5,<9.5.8|>=10,<10.0.8", + "drupal/core": "<9.5.11|>=10,<10.0.11|>=10.1,<10.1.4", "drupal/drupal": ">=6,<6.38|>=7,<7.80|>=8,<8.9.16|>=9,<9.1.12|>=9.2,<9.2.4", "duncanmcclean/guest-entries": "<3.1.2", "dweeves/magmi": "<=0.7.24", @@ -4509,7 +4506,7 @@ "ezsystems/ezplatform-solr-search-engine": ">=1.7,<1.7.12|>=2,<2.0.2|>=3.3,<3.3.15", "ezsystems/ezplatform-user": ">=1,<1.0.1", "ezsystems/ezpublish-kernel": "<6.13.8.2-dev|>=7,<7.5.31", - "ezsystems/ezpublish-legacy": "<=2017.12.7.3|>=2018.6,<=2019.03.5.1", + "ezsystems/ezpublish-legacy": "<=2017.12.7.3|>=2018.06,<=2019.03.5.1", "ezsystems/platform-ui-assets-bundle": ">=4.2,<4.2.3", "ezsystems/repository-forms": ">=2.3,<2.3.2.1-dev|>=2.5,<2.5.15", "ezyang/htmlpurifier": "<4.1.1", @@ -4522,8 +4519,8 @@ "firebase/php-jwt": "<6", "fixpunkt/fp-masterquiz": "<2.2.1|>=3,<3.5.2", "fixpunkt/fp-newsletter": "<1.1.1|>=2,<2.1.2|>=2.2,<3.2.6", - "flarum/core": "<1.8", - "flarum/framework": "<1.8", + "flarum/core": "<1.8.5", + "flarum/framework": "<1.8.5", "flarum/mentions": "<1.6.3", "flarum/sticky": ">=0.1.0.0-beta14,<=0.1.0.0-beta15", "flarum/tags": "<=0.1.0.0-beta13", @@ -4543,7 +4540,7 @@ "friendsoftypo3/mediace": ">=7.6.2,<7.6.5", "friendsoftypo3/openid": ">=4.5,<4.5.31|>=4.7,<4.7.16|>=6,<6.0.11|>=6.1,<6.1.6", "froala/wysiwyg-editor": "<3.2.7|>=4.0.1,<=4.1.1", - "froxlor/froxlor": "<2.1.0.0-beta1", + "froxlor/froxlor": "<=2.1.1", "fuel/core": "<1.8.1", "funadmin/funadmin": "<=3.2|>=3.3.2,<=3.3.3", "gaoming13/wechat-php-sdk": "<=1.10.2", @@ -4553,7 +4550,7 @@ "getkirby/kirby": "<=2.5.12", "getkirby/panel": "<2.5.14", "getkirby/starterkit": "<=3.7.0.2", - "gilacms/gila": "<=1.11.4", + "gilacms/gila": "<=1.15.4", "gleez/cms": "<=1.2|==2", "globalpayments/php-sdk": "<2", "gogentooss/samlbase": "<1.2.7", @@ -4561,7 +4558,7 @@ "gos/web-socket-bundle": "<1.10.4|>=2,<2.6.1|>=3,<3.3", "gree/jose": "<2.2.1", "gregwar/rst": "<1.0.3", - "grumpydictator/firefly-iii": "<6", + "grumpydictator/firefly-iii": "<6.1.1", "gugoan/economizzer": "<=0.9.0.0-beta1", "guzzlehttp/guzzle": "<6.5.8|>=7,<7.4.5", "guzzlehttp/psr7": "<1.9.1|>=2,<2.4.5", @@ -4589,7 +4586,7 @@ "illuminate/encryption": ">=4,<=4.0.11|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.40|>=5.6,<5.6.15", "illuminate/view": "<6.20.42|>=7,<7.30.6|>=8,<8.75", "impresscms/impresscms": "<=1.4.5", - "in2code/femanager": "<5.5.3|>=6,<6.3.4|>=7,<7.2.2", + "in2code/femanager": "<5.5.3|>=6,<6.3.4|>=7,<7.2.3", "in2code/ipandlanguageredirect": "<5.1.2", "in2code/lux": "<17.6.1|>=18,<24.0.2", "innologi/typo3-appointments": "<2.0.6", @@ -4612,6 +4609,7 @@ "joyqi/hyper-down": "<=2.4.27", "jsdecena/laracom": "<2.0.9", "jsmitty12/phpwhois": "<5.1", + "juzaweb/cms": "<=3.4", "kazist/phpwhois": "<=4.2.6", "kelvinmo/simplexrd": "<3.1.1", "kevinpapst/kimai2": "<1.16.7", @@ -4645,17 +4643,21 @@ "lms/routes": "<2.1.1", "localizationteam/l10nmgr": "<7.4|>=8,<8.7|>=9,<9.2", "luyadev/yii-helpers": "<1.2.1", - "magento/community-edition": "<=2.4", + "magento/community-edition": "<2.4.3.0-patch3|>=2.4.4,<2.4.5", + "magento/core": "<=1.9.4.5", "magento/magento1ce": "<1.9.4.3-dev", "magento/magento1ee": ">=1,<1.14.4.3-dev", "magento/product-community-edition": ">=2,<2.2.10|>=2.3,<2.3.2.0-patch2", + "magneto/core": "<1.9.4.4-dev", "maikuolan/phpmussel": ">=1,<1.6", + "mainwp/mainwp": "<=4.4.3.3", "mantisbt/mantisbt": "<=2.25.7", "marcwillmann/turn": "<0.3.3", "matyhtf/framework": "<3.0.6", "mautic/core": "<4.3", "mediawiki/core": ">=1.27,<1.27.6|>=1.29,<1.29.3|>=1.30,<1.30.2|>=1.31,<1.31.9|>=1.32,<1.32.6|>=1.32.99,<1.33.3|>=1.33.99,<1.34.3|>=1.34.99,<1.35", "mediawiki/matomo": "<2.4.3", + "mediawiki/semantic-media-wiki": "<4.0.2", "melisplatform/melis-asset-manager": "<5.0.1", "melisplatform/melis-cms": "<5.0.1", "melisplatform/melis-front": "<5.0.1", @@ -4710,7 +4712,7 @@ "open-web-analytics/open-web-analytics": "<1.7.4", "opencart/opencart": "<=3.0.3.7|>=4,<4.0.2.3-dev", "openid/php-openid": "<2.3", - "openmage/magento-lts": "<=19.5|>=20,<=20.1", + "openmage/magento-lts": "<20.2", "opensource-workshop/connect-cms": "<1.7.2|>=2,<2.3.2", "orchid/platform": ">=9,<9.4.4|>=14.0.0.0-alpha4,<14.5", "oro/calendar-bundle": ">=4.2,<=4.2.6|>=5,<=5.0.6|>=5.1,<5.1.1", @@ -4733,8 +4735,10 @@ "pegasus/google-for-jobs": "<1.5.1|>=2,<2.1.1", "personnummer/personnummer": "<3.0.2", "phanan/koel": "<5.1.4", + "phenx/php-svg-lib": "<0.5.1", "php-mod/curl": "<2.3.2", "phpbb/phpbb": "<3.2.10|>=3.3,<3.3.1", + "phpems/phpems": ">=6,<=6.1.3", "phpfastcache/phpfastcache": "<6.1.5|>=7,<7.1.2|>=8,<8.0.7", "phpmailer/phpmailer": "<6.5", "phpmussel/phpmussel": ">=1,<1.6", @@ -4744,19 +4748,21 @@ "phpoffice/phpspreadsheet": "<1.16", "phpseclib/phpseclib": "<2.0.31|>=3,<3.0.34", "phpservermon/phpservermon": "<3.6", - "phpsysinfo/phpsysinfo": "<3.2.5", + "phpsysinfo/phpsysinfo": "<3.4.3", "phpunit/phpunit": ">=4.8.19,<4.8.28|>=5,<5.6.3", "phpwhois/phpwhois": "<=4.2.5", "phpxmlrpc/extras": "<0.6.1", "phpxmlrpc/phpxmlrpc": "<4.9.2", "pi/pi": "<=2.5", "pimcore/admin-ui-classic-bundle": "<1.2.2", - "pimcore/customer-management-framework-bundle": "<3.4.2", + "pimcore/customer-management-framework-bundle": "<4.0.6", "pimcore/data-hub": "<1.2.4", "pimcore/demo": "<10.3", + "pimcore/ecommerce-framework-bundle": "<1.0.10", "pimcore/perspective-editor": "<1.5.1", "pimcore/pimcore": "<11.1.1", "pixelfed/pixelfed": "<=0.11.4", + "plotly/plotly.js": "<2.25.2", "pocketmine/bedrock-protocol": "<8.0.2", "pocketmine/pocketmine-mp": "<=4.23|>=5,<5.3.1", "pocketmine/raklib": ">=0.14,<0.14.6|>=0.15,<0.15.1", @@ -4766,7 +4772,7 @@ "prestashop/blockwishlist": ">=2,<2.1.1", "prestashop/contactform": ">=1.0.1,<4.3", "prestashop/gamification": "<2.3.2", - "prestashop/prestashop": "<8.1.2", + "prestashop/prestashop": "<8.1.3", "prestashop/productcomments": "<5.0.2", "prestashop/ps_emailsubscription": "<2.6.1", "prestashop/ps_facetedsearch": "<3.4.1", @@ -4904,8 +4910,10 @@ "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4", "symfony/webhook": ">=6.3,<6.3.8", "symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7", + "symphonycms/symphony-2": "<2.6.4", "t3/dce": "<0.11.5|>=2.2,<2.6.2", "t3g/svg-sanitizer": "<1.0.3", + "t3s/content-consent": "<1.0.3|>=2,<2.0.2", "tastyigniter/tastyigniter": "<3.3", "tcg/voyager": "<=1.4", "tecnickcom/tcpdf": "<6.2.22", @@ -4930,7 +4938,7 @@ "twig/twig": "<1.44.7|>=2,<2.15.3|>=3,<3.4.3", "typo3/cms": "<9.5.29|>=10,<10.4.35|>=11,<11.5.23|>=12,<12.2", "typo3/cms-backend": ">=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", - "typo3/cms-core": "<=8.7.54|>=9,<=9.5.43|>=10,<=10.4.40|>=11,<=11.5.32|>=12,<=12.4.7", + "typo3/cms-core": "<8.7.55|>=9,<9.5.44|>=10,<10.4.41|>=11,<11.5.33|>=12,<12.4.8", "typo3/cms-extbase": "<6.2.24|>=7,<7.6.8|==8.1.1", "typo3/cms-form": ">=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", "typo3/cms-install": ">=12.2,<12.4.8", @@ -4943,12 +4951,12 @@ "typo3fluid/fluid": ">=2,<2.0.8|>=2.1,<2.1.7|>=2.2,<2.2.4|>=2.3,<2.3.7|>=2.4,<2.4.4|>=2.5,<2.5.11|>=2.6,<2.6.10", "ua-parser/uap-php": "<3.8", "uasoft-indonesia/badaso": "<=2.9.7", - "unisharp/laravel-filemanager": "<=2.5.1", + "unisharp/laravel-filemanager": "<2.6.4", "userfrosting/userfrosting": ">=0.3.1,<4.6.3", "usmanhalalit/pixie": "<1.0.3|>=2,<2.0.2", "uvdesk/community-skeleton": "<=1.1.1", "vanilla/safecurl": "<0.9.2", - "verot/class.upload.php": "<=1.0.3|>=2,<=2.0.4", + "verot/class.upload.php": "<=2.1.6", "vova07/yii2-fileapi-widget": "<0.1.9", "vrana/adminer": "<4.8.1", "waldhacker/hcaptcha": "<2.1.2", @@ -4964,6 +4972,8 @@ "wikibase/wikibase": "<=1.39.3", "wikimedia/parsoid": "<0.12.2", "willdurand/js-translation-bundle": "<2.1.1", + "winter/wn-backend-module": "<1.2.4", + "winter/wn-system-module": "<1.2.4", "wintercms/winter": "<1.2.3", "woocommerce/woocommerce": "<6.6", "wp-cli/wp-cli": "<2.5", @@ -4979,6 +4989,7 @@ "yii2mod/yii2-cms": "<1.9.2", "yiisoft/yii": "<1.1.29", "yiisoft/yii2": "<2.0.38", + "yiisoft/yii2-authclient": "<2.2.15", "yiisoft/yii2-bootstrap": "<2.0.4", "yiisoft/yii2-dev": "<2.0.43", "yiisoft/yii2-elasticsearch": "<2.0.5", @@ -5024,7 +5035,7 @@ "zf-commons/zfc-user": "<1.2.2", "zfcampus/zf-apigility-doctrine": "<1.0.3", "zfr/zfr-oauth2-server-module": "<0.1.2", - "zoujingli/thinkadmin": "<6.0.22" + "zoujingli/thinkadmin": "<=6.1.53" }, "default-branch": true, "type": "metapackage", @@ -5062,7 +5073,7 @@ "type": "tidelift" } ], - "time": "2023-12-06T18:04:43+00:00" + "time": "2024-01-11T20:04:14+00:00" }, { "name": "sebastian/cli-parser", @@ -5310,20 +5321,20 @@ }, { "name": "sebastian/complexity", - "version": "3.1.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "68cfb347a44871f01e33ab0ef8215966432f6957" + "reference": "68ff824baeae169ec9f2137158ee529584553799" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68cfb347a44871f01e33ab0ef8215966432f6957", - "reference": "68cfb347a44871f01e33ab0ef8215966432f6957", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", + "reference": "68ff824baeae169ec9f2137158ee529584553799", "shasum": "" }, "require": { - "nikic/php-parser": "^4.10", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1" }, "require-dev": { @@ -5332,7 +5343,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.1-dev" + "dev-main": "3.2-dev" } }, "autoload": { @@ -5356,7 +5367,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", "security": "https://github.com/sebastianbergmann/complexity/security/policy", - "source": "https://github.com/sebastianbergmann/complexity/tree/3.1.0" + "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" }, "funding": [ { @@ -5364,20 +5375,20 @@ "type": "github" } ], - "time": "2023-09-28T11:50:59+00:00" + "time": "2023-12-21T08:37:17+00:00" }, { "name": "sebastian/diff", - "version": "5.0.3", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b" + "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b", - "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/fbf413a49e54f6b9b17e12d900ac7f6101591b7f", + "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f", "shasum": "" }, "require": { @@ -5390,7 +5401,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -5423,7 +5434,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/diff/tree/5.1.0" }, "funding": [ { @@ -5431,7 +5442,7 @@ "type": "github" } ], - "time": "2023-05-01T07:48:21+00:00" + "time": "2023-12-22T10:55:06+00:00" }, { "name": "sebastian/environment", @@ -5639,20 +5650,20 @@ }, { "name": "sebastian/lines-of-code", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d" + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/649e40d279e243d985aa8fb6e74dd5bb28dc185d", - "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", "shasum": "" }, "require": { - "nikic/php-parser": "^4.10", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1" }, "require-dev": { @@ -5685,7 +5696,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.1" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" }, "funding": [ { @@ -5693,7 +5704,7 @@ "type": "github" } ], - "time": "2023-08-31T09:25:50+00:00" + "time": "2023-12-21T08:38:20+00:00" }, { "name": "sebastian/object-enumerator", @@ -5981,16 +5992,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.2", + "version": "3.8.1", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", "shasum": "" }, "require": { @@ -6000,11 +6011,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -6019,22 +6030,45 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", "standards", "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2023-02-22T23:07:41+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-01-11T20:47:48+00:00" }, { "name": "symfony/browser-kit", diff --git a/lib/SP/Domain/Client/Adapters/ClientAdapter.php b/lib/SP/Domain/Client/Adapters/ClientAdapter.php index e77b97ec..56a67cc9 100644 --- a/lib/SP/Domain/Client/Adapters/ClientAdapter.php +++ b/lib/SP/Domain/Client/Adapters/ClientAdapter.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\Domain\Client\Adapters; use League\Fractal\Resource\Collection; -use SP\DataModel\ClientData; +use SP\Domain\Client\Models\Client; use SP\Domain\Client\Ports\ClientAdapterInterface; use SP\Domain\Common\Adapters\Adapter; use SP\Domain\Common\Services\ServiceException; @@ -55,7 +55,7 @@ final class ClientAdapter extends Adapter implements ClientAdapterInterface * @throws SPException * @throws ServiceException */ - public function includeCustomFields(ClientData $data, CustomFieldServiceInterface $customFieldService): Collection + public function includeCustomFields(Client $data, CustomFieldServiceInterface $customFieldService): Collection { return $this->collection( $this->getCustomFieldsForItem(AclActionsInterface::CLIENT, $data->id, $customFieldService), @@ -63,7 +63,7 @@ final class ClientAdapter extends Adapter implements ClientAdapterInterface ); } - public function transform(ClientData $data): array + public function transform(Client $data): array { return [ 'id' => $data->getId(), diff --git a/lib/SP/DataModel/ClientData.php b/lib/SP/Domain/Client/Models/Client.php similarity index 54% rename from lib/SP/DataModel/ClientData.php rename to lib/SP/Domain/Client/Models/Client.php index 50cfaf88..7d026bdc 100644 --- a/lib/SP/DataModel/ClientData.php +++ b/lib/SP/Domain/Client/Models/Client.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. * @@ -22,67 +22,38 @@ * along with sysPass. If not, see . */ -namespace SP\DataModel; +namespace SP\Domain\Client\Models; use SP\Domain\Common\Adapters\DataModelInterface; use SP\Domain\Common\Models\Model; -defined('APP_ROOT') || die(); - /** - * Class ClientData - * - * @package SP\DataModel + * Class Client */ -class ClientData extends Model implements DataModelInterface +class Client extends Model implements DataModelInterface { - public ?int $id = null; - public ?string $name = null; - public ?string $description = null; - public ?string $hash = null; - public ?int $isGlobal = null; - - public function __construct( - ?int $id = null, - ?string $name = null, - ?string $description = null - ) - { - $this->id = $id; - $this->name = $name; - $this->description = $description; - } + public ?int $isGlobal = null; + protected ?int $id = null; + protected ?string $name = null; + protected ?string $description = null; + protected ?string $hash = null; public function getId(): ?int { return $this->id; } - public function setId(int $id): void - { - $this->id = $id; - } - public function getName(): ?string { return $this->name; } - public function setName(string $name): void - { - $this->name = $name; - } public function getDescription(): ?string { return $this->description; } - public function setDescription(?string $description): void - { - $this->description = $description; - } - public function getHash(): ?string { return $this->hash; @@ -92,9 +63,4 @@ class ClientData extends Model implements DataModelInterface { return $this->isGlobal; } - - public function setIsGlobal(?int $isGlobal): void - { - $this->isGlobal = $isGlobal; - } } diff --git a/lib/SP/Domain/Client/Ports/ClientAdapterInterface.php b/lib/SP/Domain/Client/Ports/ClientAdapterInterface.php index b73460cc..a34132f8 100644 --- a/lib/SP/Domain/Client/Ports/ClientAdapterInterface.php +++ b/lib/SP/Domain/Client/Ports/ClientAdapterInterface.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\Domain\Client\Ports; use League\Fractal\Resource\Collection; -use SP\DataModel\ClientData; +use SP\Domain\Client\Models\Client; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Exceptions\ConstraintException; use SP\Domain\Core\Exceptions\QueryException; @@ -45,7 +45,7 @@ interface ClientAdapterInterface * @throws SPException * @throws ServiceException */ - public function includeCustomFields(ClientData $data, CustomFieldServiceInterface $customFieldService): Collection; + public function includeCustomFields(Client $data, CustomFieldServiceInterface $customFieldService): Collection; - public function transform(ClientData $data): array; + public function transform(Client $data): array; } diff --git a/lib/SP/Domain/Client/Ports/ClientRepositoryInterface.php b/lib/SP/Domain/Client/Ports/ClientRepositoryInterface.php index 45361917..968875ab 100644 --- a/lib/SP/Domain/Client/Ports/ClientRepositoryInterface.php +++ b/lib/SP/Domain/Client/Ports/ClientRepositoryInterface.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. * @@ -24,39 +24,104 @@ namespace SP\Domain\Client\Ports; - +use SP\DataModel\ItemSearchData; +use SP\Domain\Account\Ports\AccountFilterUserInterface; +use SP\Domain\Client\Models\Client; use SP\Domain\Common\Ports\RepositoryInterface; use SP\Domain\Core\Exceptions\ConstraintException; use SP\Domain\Core\Exceptions\QueryException; +use SP\Domain\Core\Exceptions\SPException; +use SP\Infrastructure\Common\Repositories\DuplicatedItemException; use SP\Infrastructure\Database\QueryResult; -use SP\Mvc\Model\QueryCondition; /** * Class ClientRepository * - * @package SP\Infrastructure\Common\Repositories\Client + * @template T of Client */ interface ClientRepositoryInterface extends RepositoryInterface { /** - * Returns the item for given name + * Creates an item * - * @param string $name + * @param Client $client * * @return QueryResult + * @throws DuplicatedItemException + * @throws SPException + */ + public function create(Client $client): QueryResult; + + /** + * Updates an item + * + * @param Client $client + * + * @return int + * @throws ConstraintException + * @throws QueryException + * @throws DuplicatedItemException + */ + public function update(Client $client): int; + + /** + * Returns the item for given id + * + * @param int $clientId + * + * @return QueryResult + */ + public function getById(int $clientId): QueryResult; + + /** + * Deletes all the items for given ids + * + * @param array $clientIds + * + * @return QueryResult + * @throws ConstraintException + * @throws QueryException + */ + public function deleteByIdBatch(array $clientIds): QueryResult; + + /** + * Deletes an item + * + * @param int $id + * + * @return QueryResult + * @throws ConstraintException + * @throws QueryException + */ + public function delete(int $id): QueryResult; + + /** + * Searches for items by a given filter + * + * @param ItemSearchData $itemSearchData + * + * @return QueryResult + */ + public function search(ItemSearchData $itemSearchData): QueryResult; + + /** + * Returns the item for given name + * + * @param string $name + * + * @return QueryResult * @throws QueryException * @throws ConstraintException */ public function getByName(string $name): QueryResult; /** - * Devolver los clientes visibles por el usuario + * Return the clients visible for the current user * - * @param QueryCondition $queryFilter - * - * @return QueryResult + * @param AccountFilterUserInterface $accountFilterUser + * @return QueryResult * @throws QueryException * @throws ConstraintException */ - public function getAllForFilter(QueryCondition $queryFilter): QueryResult; + public function getAllForFilter(AccountFilterUserInterface $accountFilterUser): QueryResult; } diff --git a/lib/SP/Domain/Client/Ports/ClientServiceInterface.php b/lib/SP/Domain/Client/Ports/ClientServiceInterface.php index f03c4a2c..183929b0 100644 --- a/lib/SP/Domain/Client/Ports/ClientServiceInterface.php +++ b/lib/SP/Domain/Client/Ports/ClientServiceInterface.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,9 +25,9 @@ namespace SP\Domain\Client\Ports; -use SP\DataModel\ClientData; use SP\DataModel\ItemData; use SP\DataModel\ItemSearchData; +use SP\Domain\Client\Models\Client; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Exceptions\ConstraintException; use SP\Domain\Core\Exceptions\QueryException; @@ -54,7 +54,7 @@ interface ClientServiceInterface * @throws ConstraintException * @throws QueryException */ - public function getById(int $id): ClientData; + public function getById(int $id): Client; /** * Returns the item for given name @@ -63,7 +63,7 @@ interface ClientServiceInterface * @throws QueryException * @throws NoSuchItemException */ - public function getByName(string $name): ?ClientData; + public function getByName(string $name): ?Client; /** * @throws ConstraintException @@ -88,19 +88,19 @@ interface ClientServiceInterface public function create($itemData): int; /** - * @param ClientData $itemData + * @param Client $itemData * * @return int * @throws SPException * @throws ConstraintException * @throws QueryException */ - public function update(ClientData $itemData): int; + public function update(Client $itemData): int; /** * Get all items from the service's repository * - * @return ClientData[] + * @return Client[] * @throws ConstraintException * @throws QueryException */ diff --git a/lib/SP/Domain/Client/Services/ClientService.php b/lib/SP/Domain/Client/Services/ClientService.php index 229dbb01..676dc67d 100644 --- a/lib/SP/Domain/Client/Services/ClientService.php +++ b/lib/SP/Domain/Client/Services/ClientService.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,10 +25,10 @@ namespace SP\Domain\Client\Services; use SP\Core\Application; -use SP\DataModel\ClientData; use SP\DataModel\ItemData; use SP\DataModel\ItemSearchData; use SP\Domain\Account\Ports\AccountFilterUserInterface; +use SP\Domain\Client\Models\Client; use SP\Domain\Client\Ports\ClientRepositoryInterface; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Common\Services\Service; @@ -78,7 +78,7 @@ final class ClientService extends Service implements ClientServiceInterface * @throws ConstraintException * @throws QueryException */ - public function getById(int $id): ClientData + public function getById(int $id): Client { $result = $this->clientRepository->getById($id); @@ -96,7 +96,7 @@ final class ClientService extends Service implements ClientServiceInterface * @throws QueryException * @throws NoSuchItemException */ - public function getByName(string $name): ?ClientData + public function getByName(string $name): ?Client { $result = $this->clientRepository->getByName($name); @@ -153,11 +153,11 @@ final class ClientService extends Service implements ClientServiceInterface } /** - * @param ClientData $itemData + * @param Client $itemData * * @return int */ - public function update(ClientData $itemData): int + public function update(Client $itemData): int { return $this->clientRepository->update($itemData); } @@ -165,7 +165,7 @@ final class ClientService extends Service implements ClientServiceInterface /** * Get all items from the service's repository * - * @return ClientData[] + * @return \SP\Domain\Client\Models\Client[] * @throws ConstraintException * @throws QueryException */ @@ -183,6 +183,6 @@ final class ClientService extends Service implements ClientServiceInterface */ public function getAllForUser(): array { - return $this->clientRepository->getAllForFilter($this->accountFilterUser->buildFilter())->getDataAsArray(); + return $this->clientRepository->getAllForFilter($this->accountFilterUser)->getDataAsArray(); } } diff --git a/lib/SP/Domain/Import/Services/CsvImportBase.php b/lib/SP/Domain/Import/Services/CsvImportBase.php index b3f6a54c..84319ad6 100644 --- a/lib/SP/Domain/Import/Services/CsvImportBase.php +++ b/lib/SP/Domain/Import/Services/CsvImportBase.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. * @@ -29,9 +29,9 @@ use SP\Core\Application; use SP\Core\Events\Event; use SP\Core\Events\EventDispatcher; use SP\Core\Events\EventMessage; -use SP\DataModel\ClientData; use SP\Domain\Account\Dtos\AccountRequest; use SP\Domain\Category\Models\Category; +use SP\Domain\Client\Models\Client; use SP\Domain\Core\Exceptions\SPException; use SP\Infrastructure\File\FileException; @@ -109,7 +109,7 @@ abstract class CsvImportBase } // Obtener los ids de cliente y categoría - $clientId = $this->addClient(new ClientData(null, $clientName)); + $clientId = $this->addClient(new Client(null, $clientName)); $categoryId = $this->addCategory(new Category(null, $categoryName)); // Crear la nueva cuenta diff --git a/lib/SP/Domain/Import/Services/ImportTrait.php b/lib/SP/Domain/Import/Services/ImportTrait.php index 14268374..4e63ff4b 100644 --- a/lib/SP/Domain/Import/Services/ImportTrait.php +++ b/lib/SP/Domain/Import/Services/ImportTrait.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,12 +26,12 @@ namespace SP\Domain\Import\Services; use Defuse\Crypto\Exception\CryptoException; use SP\Core\Crypt\Crypt; -use SP\DataModel\ClientData; use SP\DataModel\TagData; use SP\Domain\Account\Dtos\AccountRequest; use SP\Domain\Account\Ports\AccountServiceInterface; use SP\Domain\Category\Models\Category; use SP\Domain\Category\Ports\CategoryServiceInterface; +use SP\Domain\Client\Models\Client; use SP\Domain\Client\Ports\ClientServiceInterface; use SP\Domain\Core\Exceptions\ConstraintException; use SP\Domain\Core\Exceptions\NoSuchPropertyException; @@ -172,13 +172,13 @@ trait ImportTrait /** * Añadir un cliente y devolver el Id * - * @param ClientData $clientData + * @param Client $clientData * * @return int * @throws DuplicatedItemException * @throws SPException */ - protected function addClient(ClientData $clientData): int + protected function addClient(Client $clientData): int { try { $clientId = $this->getWorkingItem('client', $clientData->getName()); diff --git a/lib/SP/Domain/Import/Services/KeepassImport.php b/lib/SP/Domain/Import/Services/KeepassImport.php index 826adca0..1edf312b 100644 --- a/lib/SP/Domain/Import/Services/KeepassImport.php +++ b/lib/SP/Domain/Import/Services/KeepassImport.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. * @@ -29,9 +29,9 @@ use DOMXPath; use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; -use SP\DataModel\ClientData; use SP\Domain\Account\Dtos\AccountRequest; use SP\Domain\Category\Models\Category; +use SP\Domain\Client\Models\Client; use SP\Domain\Core\Exceptions\SPException; use SP\Util\Filter; @@ -68,7 +68,7 @@ final class KeepassImport extends XmlImportBase implements ImportInterface */ private function process(): void { - $clientId = $this->addClient(new ClientData(null, 'KeePass')); + $clientId = $this->addClient(new Client(null, 'KeePass')); $this->eventDispatcher->notify( 'run.import.keepass.process.client', diff --git a/lib/SP/Domain/Import/Services/SyspassImport.php b/lib/SP/Domain/Import/Services/SyspassImport.php index 065b044b..7167c11e 100644 --- a/lib/SP/Domain/Import/Services/SyspassImport.php +++ b/lib/SP/Domain/Import/Services/SyspassImport.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,10 +34,10 @@ use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Hash; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; -use SP\DataModel\ClientData; use SP\DataModel\TagData; use SP\Domain\Account\Dtos\AccountRequest; use SP\Domain\Category\Models\Category; +use SP\Domain\Client\Models\Client; use SP\Domain\Core\Exceptions\SPException; use SP\Domain\Export\Services\XmlVerifyService; use SP\Util\VersionUtil; @@ -279,7 +279,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface 'Clients', 'Client', function (DOMElement $client) { - $clientData = new ClientData(); + $clientData = new Client(); foreach ($client->childNodes as $node) { if (isset($node->tagName)) { @@ -330,7 +330,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface 'Customers', 'Customer', function (DOMElement $client) { - $clientData = new ClientData(); + $clientData = new Client(); foreach ($client->childNodes as $node) { if (isset($node->tagName)) { diff --git a/lib/SP/Infrastructure/Client/Repositories/ClientRepository.php b/lib/SP/Infrastructure/Client/Repositories/ClientRepository.php index 57c5180d..b2e03e1f 100644 --- a/lib/SP/Infrastructure/Client/Repositories/ClientRepository.php +++ b/lib/SP/Infrastructure/Client/Repositories/ClientRepository.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. * @@ -24,10 +24,9 @@ namespace SP\Infrastructure\Client\Repositories; -use RuntimeException; -use SP\DataModel\ClientData; -use SP\DataModel\ItemData; use SP\DataModel\ItemSearchData; +use SP\Domain\Account\Ports\AccountFilterUserInterface; +use SP\Domain\Client\Models\Client; use SP\Domain\Client\Ports\ClientRepositoryInterface; use SP\Domain\Core\Exceptions\ConstraintException; use SP\Domain\Core\Exceptions\QueryException; @@ -37,104 +36,102 @@ use SP\Infrastructure\Common\Repositories\Repository; use SP\Infrastructure\Common\Repositories\RepositoryItemTrait; use SP\Infrastructure\Database\QueryData; use SP\Infrastructure\Database\QueryResult; -use SP\Mvc\Model\QueryCondition; + +use function SP\__u; /** * Class ClientRepository * - * @package SP\Infrastructure\Common\Repositories\Client + * @template T of Client */ final class ClientRepository extends Repository implements ClientRepositoryInterface { use RepositoryItemTrait; + public const TABLE = 'Client'; + /** * Creates an item * - * @param ClientData $itemData + * @param Client $client * - * @return int + * @return QueryResult * @throws DuplicatedItemException * @throws SPException */ - public function create($itemData): int + public function create(Client $client): QueryResult { - if ($this->checkDuplicatedOnAdd($itemData)) { - throw new DuplicatedItemException(__u('Duplicated client'), SPException::WARNING); + if ($this->checkDuplicatedOnAdd($client)) { + throw new DuplicatedItemException(__u('Duplicated client')); } - $query = /** @lang SQL */ - 'INSERT INTO Client - SET `name` = ?, - description = ?, - isGlobal = ?, - `hash` = ?'; + $query = $this->queryFactory + ->newInsert() + ->into(self::TABLE) + ->cols($client->toArray(null, ['id', 'hash'])) + ->col('hash', $this->makeItemHash($client->getName())); - $queryData = new QueryData(); - $queryData->setQuery($query); - $queryData->setParams([ - $itemData->getName(), - $itemData->getDescription(), - $itemData->getIsGlobal(), - $this->makeItemHash($itemData->getName()), - ]); - $queryData->setOnErrorMessage(__u('Error while creating the client')); + $queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the client')); - return $this->db->doQuery($queryData)->getLastId(); + return $this->db->doQuery($queryData); } /** * Checks whether the item is duplicated on adding * - * @param ClientData $itemData - * + * @param Client $client * @return bool * @throws ConstraintException * @throws QueryException */ - public function checkDuplicatedOnAdd($itemData): bool + private function checkDuplicatedOnAdd(Client $client): bool { - $queryData = new QueryData(); - $queryData->setQuery('SELECT id FROM Client WHERE `hash` = ? LIMIT 1'); - $queryData->addParam($this->makeItemHash($itemData->getName())); + $query = $this->queryFactory + ->newSelect() + ->cols(['id']) + ->from(self::TABLE) + ->where('hash = :hash') + ->orWhere('name = :name') + ->bindValues( + [ + 'hash' => $client->getHash(), + 'name' => $client->getName() + ] + ); - return $this->db->doQuery($queryData)->getNumRows() > 0; + return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0; } /** * Updates an item * - * @param ClientData $itemData + * @param Client $client * * @return int * @throws ConstraintException * @throws QueryException * @throws DuplicatedItemException */ - public function update($itemData): int + public function update(Client $client): int { - if ($this->checkDuplicatedOnUpdate($itemData)) { - throw new DuplicatedItemException(__u('Duplicated client'), SPException::WARNING); + if ($this->checkDuplicatedOnUpdate($client)) { + throw new DuplicatedItemException(__u('Duplicated client')); } - $query = /** @lang SQL */ - 'UPDATE Client - SET `name` = ?, - description = ?, - isGlobal = ?, - `hash` = ? - WHERE id = ? LIMIT 1'; + $query = $this->queryFactory + ->newUpdate() + ->table(self::TABLE) + ->cols($client->toArray(null, ['id', 'hash'])) + ->where('id = :id') + ->limit(1) + ->bindValues( + [ + 'id' => $client->getId(), + 'hash' => $this->makeItemHash($client->getName()) + ] + ); - $queryData = new QueryData(); - $queryData->setQuery($query); - $queryData->setParams([ - $itemData->getName(), - $itemData->getDescription(), - $itemData->getIsGlobal(), - $this->makeItemHash($itemData->getName()), - $itemData->getId(), - ]); - $queryData->setOnErrorMessage(__u('Error while updating the client')); + $queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the client')); return $this->db->doQuery($queryData)->getAffectedNumRows(); } @@ -142,40 +139,49 @@ final class ClientRepository extends Repository implements ClientRepositoryInter /** * Checks whether the item is duplicated on updating * - * @param ClientData $itemData + * @param Client $client * * @return bool * @throws ConstraintException * @throws QueryException */ - public function checkDuplicatedOnUpdate($itemData): bool + private function checkDuplicatedOnUpdate(Client $client): bool { - $queryData = new QueryData(); - $queryData->setQuery('SELECT id FROM Client WHERE (`hash` = ? OR `name` = ?) AND id <> ?'); - $queryData->setParams([ - $this->makeItemHash($itemData->getName()), - $itemData->getName(), - $itemData->getId(), - ]); + $query = $this->queryFactory + ->newSelect() + ->cols(['id']) + ->from(self::TABLE) + ->where('(hash = :hash OR name = :name)') + ->where('id <> :id') + ->bindValues( + [ + 'id' => $client->getId(), + 'hash' => $client->getHash(), + 'name' => $client->getName(), + ] + ); - return $this->db->doQuery($queryData)->getNumRows() > 0; + return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0; } /** * Returns the item for given id * - * @param int $id + * @param int $clientId * - * @return QueryResult - * @throws QueryException - * @throws ConstraintException + * @return QueryResult */ - public function getById(int $id): QueryResult + public function getById(int $clientId): QueryResult { - $queryData = new QueryData(); - $queryData->setMapClassName(ClientData::class); - $queryData->setQuery('SELECT id, `name`, description, isGlobal FROM Client WHERE id = ? LIMIT 1'); - $queryData->addParam($id); + $query = $this->queryFactory + ->newSelect() + ->from(self::TABLE) + ->cols(Client::getCols()) + ->where('id = :id') + ->bindValues(['id' => $clientId]) + ->limit(1); + + $queryData = QueryData::buildWithMapper($query, Client::class); return $this->db->doSelect($queryData); } @@ -183,23 +189,21 @@ final class ClientRepository extends Repository implements ClientRepositoryInter /** * Returns the item for given name * - * @param string $name + * @param string $name * - * @return QueryResult - * @throws QueryException - * @throws ConstraintException + * @return QueryResult */ public function getByName(string $name): QueryResult { - $queryData = new QueryData(); - $queryData->setMapClassName(ClientData::class); - $queryData->setQuery( - 'SELECT id, `name`, description, isGlobal FROM Client WHERE `name` = ? OR `hash` = ? LIMIT 1' - ); - $queryData->setParams([ - $name, - $this->makeItemHash($name), - ]); + $query = $this->queryFactory + ->newSelect() + ->from(self::TABLE) + ->cols(Client::getCols()) + ->where('(name = :name OR hash = :hash)') + ->bindValues(['name' => $name, 'hash' => $this->makeItemHash($name)]) + ->limit(1); + + $queryData = QueryData::buildWithMapper($query, Client::class); return $this->db->doSelect($queryData); } @@ -207,162 +211,113 @@ final class ClientRepository extends Repository implements ClientRepositoryInter /** * Returns all the items * - * @return QueryResult - * @throws QueryException - * @throws ConstraintException + * @return QueryResult */ public function getAll(): QueryResult { - $queryData = new QueryData(); - $queryData->setQuery('SELECT id, `name`, description, isGlobal FROM Client ORDER BY `name`'); - $queryData->setMapClassName(ClientData::class); + $query = $this->queryFactory + ->newSelect() + ->from(self::TABLE) + ->cols(Client::getCols()); - return $this->db->doSelect($queryData); - } - - /** - * Returns all the items for given ids - * - * @param array $ids - * - * @return QueryResult - * @throws QueryException - * @throws ConstraintException - */ - public function getByIdBatch(array $ids): QueryResult - { - if (count($ids) === 0) { - return new QueryResult(); - } - - $query = /** @lang SQL */ - 'SELECT id, `name`, description, isGlobal FROM Client WHERE id IN ('.$this->buildParamsFromArray($ids).')'; - - $queryData = new QueryData(); - $queryData->setMapClassName(ClientData::class); - $queryData->setQuery($query); - $queryData->setParams($ids); - - return $this->db->doSelect($queryData); + return $this->db->doSelect(QueryData::buildWithMapper($query, Client::class)); } /** * Deletes all the items for given ids * - * @param array $ids + * @param array $clientIds * - * @return int + * @return QueryResult * @throws ConstraintException * @throws QueryException */ - public function deleteByIdBatch(array $ids): int + public function deleteByIdBatch(array $clientIds): QueryResult { - if (count($ids) === 0) { - return 0; + if (count($clientIds) === 0) { + return new QueryResult(); } - $queryData = new QueryData(); - $queryData->setQuery('DELETE FROM Client WHERE id IN ('.$this->buildParamsFromArray($ids).')'); - $queryData->setParams($ids); - $queryData->setOnErrorMessage(__u('Error while deleting the clients')); + $query = $this->queryFactory + ->newDelete() + ->from(self::TABLE) + ->where('id IN (:ids)', ['ids' => $clientIds]); - return $this->db->doQuery($queryData)->getAffectedNumRows(); + $queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the clients')); + + return $this->db->doQuery($queryData); } /** * Deletes an item * - * @param int $id + * @param int $id * - * @return int + * @return QueryResult * @throws ConstraintException * @throws QueryException */ - public function delete(int $id): int + public function delete(int $id): QueryResult { - $queryData = new QueryData(); - $queryData->setQuery('DELETE FROM Client WHERE id = ? LIMIT 1'); - $queryData->addParam($id); - $queryData->setOnErrorMessage(__u('Error while deleting the client')); + $query = $this->queryFactory + ->newDelete() + ->from(self::TABLE) + ->where('id = :id') + ->bindValues(['id' => $id]); - return $this->db->doQuery($queryData)->getAffectedNumRows(); - } + $queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the client')); - /** - * Checks whether the item is in use or not - * - * @param $id int - * - * @return void - */ - public function checkInUse(int $id): bool - { - throw new RuntimeException('Not implemented'); + return $this->db->doQuery($queryData); } /** * Searches for items by a given filter * - * @param ItemSearchData $itemSearchData + * @param ItemSearchData $itemSearchData * - * @return QueryResult - * @throws QueryException - * @throws ConstraintException + * @return QueryResult */ public function search(ItemSearchData $itemSearchData): QueryResult { - $queryData = new QueryData(); - $queryData->setMapClassName(ClientData::class); - $queryData->setSelect('id, name, description, isGlobal'); - $queryData->setFrom('Client'); - $queryData->setOrder('name'); + $query = $this->queryFactory + ->newSelect() + ->from(self::TABLE) + ->cols(Client::getCols(['hash'])) + ->orderBy(['name']) + ->limit($itemSearchData->getLimitCount()) + ->offset($itemSearchData->getLimitStart()); if (!empty($itemSearchData->getSeachString())) { - $queryData->setWhere('name LIKE ? OR description LIKE ?'); + $query->where('name LIKE :name OR description LIKE :description'); - $search = '%'.$itemSearchData->getSeachString().'%'; - $queryData->addParam($search); - $queryData->addParam($search); + $search = '%' . $itemSearchData->getSeachString() . '%'; + + $query->bindValues(['name' => $search, 'description' => $search]); } - $queryData->setLimit( - '?,?', - [$itemSearchData->getLimitStart(), $itemSearchData->getLimitCount()] - ); + $queryData = QueryData::build($query)->setMapClassName(Client::class); return $this->db->doSelect($queryData, true); } /** - * Devolver los clientes visibles por el usuario + * Return the clients visible for the current user * - * @param QueryCondition $queryFilter + * @param AccountFilterUserInterface $accountFilterUser * * @return QueryResult - * @throws QueryException - * @throws ConstraintException */ - public function getAllForFilter(QueryCondition $queryFilter): QueryResult + public function getAllForFilter(AccountFilterUserInterface $accountFilterUser): QueryResult { - if (!$queryFilter->hasFilters()) { - throw new QueryException(__u('Wrong filter')); - } + $query = $accountFilterUser + ->buildFilter() + ->cols(['Client.id', 'Client.name']) + ->join('right', 'Client', 'Account.clientId = Client.id') + ->where('Account.clientId IS NULL') + ->orWhere('Client.isGlobal = 1') + ->groupBy(['id']) + ->orderBy(['Client.name']); - $query = /** @lang SQL */ - 'SELECT Client.id, Client.name - FROM Account - RIGHT JOIN Client ON Account.clientId = Client.id - WHERE Account.clientId IS NULL - OR Client.isGlobal = 1 - OR '.$queryFilter->getFilters().' - GROUP BY id - ORDER BY Client.name'; - - $queryData = new QueryData(); - $queryData->setMapClassName(ItemData::class); - $queryData->setQuery($query); - $queryData->setParams($queryFilter->getParams()); - - return $this->db->doSelect($queryData); + return $this->db->doSelect(QueryData::build($query)); } } diff --git a/tests/SPT/Generators/ClientGenerator.php b/tests/SPT/Generators/ClientGenerator.php new file mode 100644 index 00000000..724c05a8 --- /dev/null +++ b/tests/SPT/Generators/ClientGenerator.php @@ -0,0 +1,50 @@ +. + */ + +namespace SPT\Generators; + +use SP\Domain\Client\Models\Client; + +/** + * Class ClientGenerator + */ +final class ClientGenerator extends DataGenerator +{ + + public function buildClient(): Client + { + return new Client($this->clientProperties()); + } + + private function clientProperties(): array + { + return [ + 'id' => $this->faker->randomNumber(), + 'name' => $this->faker->colorName(), + 'description' => $this->faker->text(), + 'hash' => $this->faker->sha1(), + 'isGlobal' => $this->faker->boolean() + ]; + } +} diff --git a/tests/SPT/Infrastructure/Client/Repositories/ClientRepositoryTest.php b/tests/SPT/Infrastructure/Client/Repositories/ClientRepositoryTest.php new file mode 100644 index 00000000..2b7186b6 --- /dev/null +++ b/tests/SPT/Infrastructure/Client/Repositories/ClientRepositoryTest.php @@ -0,0 +1,456 @@ +. + */ + +namespace SPT\Infrastructure\Client\Repositories; + +use Aura\SqlQuery\Common\DeleteInterface; +use Aura\SqlQuery\Common\InsertInterface; +use Aura\SqlQuery\Common\SelectInterface; +use Aura\SqlQuery\Common\UpdateInterface; +use Aura\SqlQuery\QueryFactory; +use Exception; +use PHPUnit\Framework\Constraint\Callback; +use PHPUnit\Framework\MockObject\MockObject; +use SP\DataModel\ItemSearchData; +use SP\Domain\Account\Ports\AccountFilterUserInterface; +use SP\Domain\Client\Models\Client; +use SP\Domain\Common\Models\Simple; +use SP\Domain\Core\Exceptions\ConstraintException; +use SP\Domain\Core\Exceptions\QueryException; +use SP\Domain\Core\Exceptions\SPException; +use SP\Infrastructure\Client\Repositories\ClientRepository; +use SP\Infrastructure\Common\Repositories\DuplicatedItemException; +use SP\Infrastructure\Database\DatabaseInterface; +use SP\Infrastructure\Database\QueryData; +use SP\Infrastructure\Database\QueryResult; +use SPT\Generators\ClientGenerator; +use SPT\UnitaryTestCase; + +/** + * Class ClientRepositoryTest + * + * @group unitary + */ +class ClientRepositoryTest extends UnitaryTestCase +{ + + private ClientRepository $clientRepository; + private DatabaseInterface|MockObject $database; + + /** + * @throws ConstraintException + * @throws DuplicatedItemException + * @throws QueryException + * @throws SPException + */ + public function testCreate() + { + $client = ClientGenerator::factory()->buildClient(); + + $callbackDuplicate = new Callback( + static function (QueryData $arg) use ($client) { + $query = $arg->getQuery(); + $params = $query->getBindValues(); + + return count($params) === 2 + && $params['name'] === $client->getName() + && $params['hash'] === $client->getHash() + && is_a($query, SelectInterface::class) + && !empty($query->getStatement()); + } + ); + + $callbackUpdate = new Callback( + static function (QueryData $arg) use ($client) { + $query = $arg->getQuery(); + $params = $query->getBindValues(); + + return count($params) === 4 + && $params['name'] === $client->getName() + && $params['description'] === $client->getDescription() + && $params['isGlobal'] === $client->getIsGlobal() + && !empty($params['hash']) + && is_a($query, InsertInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::exactly(2)) + ->method('doQuery') + ->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate])) + ->willReturn(new QueryResult([]), new QueryResult([1])); + + $this->clientRepository->create($client); + } + + /** + * @throws DuplicatedItemException + * @throws SPException + */ + public function testCreateWithDuplicate() + { + $client = ClientGenerator::factory()->buildClient(); + + $callbackDuplicate = new Callback( + static function (QueryData $arg) use ($client) { + $query = $arg->getQuery(); + $params = $query->getBindValues(); + + return count($params) === 2 + && $params['name'] === $client->getName() + && !empty($params['hash']) + && is_a($query, SelectInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::once()) + ->method('doQuery') + ->with($callbackDuplicate) + ->willReturn(new QueryResult([1])); + + $this->expectException(DuplicatedItemException::class); + $this->expectExceptionMessage('Duplicated client'); + + $this->clientRepository->create($client); + } + + /** + * @throws ConstraintException + * @throws QueryException + */ + public function testDelete() + { + $id = self::$faker->randomNumber(); + + $callback = new Callback( + static function (QueryData $arg) use ($id) { + $query = $arg->getQuery(); + + return $query->getBindValues()['id'] === $id + && is_a($query, DeleteInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database->expects(self::once())->method('doQuery')->with($callback); + + $this->clientRepository->delete($id); + } + + /** + * @throws ConstraintException + * @throws QueryException + */ + public function testDeleteByIdBatch() + { + $ids = [self::$faker->randomNumber(), self::$faker->randomNumber(), self::$faker->randomNumber()]; + + $callback = new Callback( + static function (QueryData $arg) use ($ids) { + $query = $arg->getQuery(); + $values = $query->getBindValues(); + + return count($values) === 3 + && array_shift($values) === array_shift($ids) + && array_shift($values) === array_shift($ids) + && array_shift($values) === array_shift($ids) + && $arg->getMapClassName() === Simple::class + && is_a($query, DeleteInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::once()) + ->method('doQuery') + ->with($callback); + + $this->clientRepository->deleteByIdBatch($ids); + } + + /** + * @throws ConstraintException + * @throws QueryException + */ + public function testDeleteByIdBatchWithNoIds(): void + { + $this->database + ->expects(self::never()) + ->method('doQuery'); + + $this->clientRepository->deleteByIdBatch([]); + } + + public function testGetById() + { + $id = self::$faker->randomNumber(); + + $callback = new Callback( + static function (QueryData $arg) use ($id) { + $query = $arg->getQuery(); + $params = $query->getBindValues(); + + return count($params) === 1 + && $params['id'] === $id + && $arg->getMapClassName() === Client::class + && is_a($query, SelectInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::once()) + ->method('doSelect') + ->with($callback); + + $this->clientRepository->getById($id); + } + + /** + * @throws Exception + */ + public function testSearch() + { + $item = new ItemSearchData(self::$faker->name); + + $callback = new Callback( + static function (QueryData $arg) use ($item) { + $query = $arg->getQuery(); + $params = $query->getBindValues(); + $searchStringLike = '%' . $item->getSeachString() . '%'; + + return count($params) === 2 + && $params['name'] === $searchStringLike + && $params['description'] === $searchStringLike + && $arg->getMapClassName() === Client::class + && is_a($query, SelectInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::once()) + ->method('doSelect') + ->with($callback, true); + + $this->clientRepository->search($item); + } + + /** + * @throws Exception + */ + public function testSearchWithoutString(): void + { + $callback = new Callback( + static function (QueryData $arg) { + $query = $arg->getQuery(); + return count($query->getBindValues()) === 0 + && $arg->getMapClassName() === Client::class + && is_a($query, SelectInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::once()) + ->method('doSelect') + ->with($callback, true); + + $this->clientRepository->search(new ItemSearchData()); + } + + public function testGetAll() + { + $callback = new Callback( + static function (QueryData $arg) { + $query = $arg->getQuery(); + return $arg->getMapClassName() === Client::class + && is_a($query, SelectInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::once()) + ->method('doSelect') + ->with($callback); + + $this->clientRepository->getAll(); + } + + /** + * @throws \PHPUnit\Framework\MockObject\Exception + */ + public function testGetAllForFilter() + { + $callback = new Callback( + static function (QueryData $arg) { + $query = $arg->getQuery(); + return $arg->getMapClassName() === Simple::class + && is_a($query, SelectInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::once()) + ->method('doSelect') + ->with($callback); + + $select = (new QueryFactory('mysql', QueryFactory::COMMON))->newSelect(); + + $accountFilterUser = $this->createMock(AccountFilterUserInterface::class); + $accountFilterUser->expects(self::once()) + ->method('buildFilter') + ->willReturn($select); + + $this->clientRepository->getAllForFilter($accountFilterUser); + } + + /** + * @throws DuplicatedItemException + * @throws ConstraintException + * @throws QueryException + */ + public function testUpdate() + { + $client = ClientGenerator::factory()->buildClient(); + + $callbackDuplicate = new Callback( + static function (QueryData $arg) use ($client) { + $query = $arg->getQuery(); + $params = $query->getBindValues(); + + return count($params) === 3 + && $params['id'] === $client->getId() + && $params['name'] === $client->getName() + && !empty($params['hash']) + && is_a($query, SelectInterface::class) + && !empty($query->getStatement()); + } + ); + + $callbackUpdate = new Callback( + static function (QueryData $arg) use ($client) { + $query = $arg->getQuery(); + $params = $query->getBindValues(); + + return count($params) === 5 + && $params['id'] === $client->getId() + && $params['name'] === $client->getName() + && $params['description'] === $client->getDescription() + && $params['isGlobal'] === $client->getIsGlobal() + && !empty($params['hash']) + && is_a($query, UpdateInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::exactly(2)) + ->method('doQuery') + ->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate])) + ->willReturn(new QueryResult([]), new QueryResult([1])); + + $this->clientRepository->update($client); + } + + /** + * @throws ConstraintException + * @throws QueryException + */ + public function testCheckDuplicatedOnUpdate() + { + $client = ClientGenerator::factory()->buildClient(); + + $callbackDuplicate = new Callback( + static function (QueryData $arg) use ($client) { + $query = $arg->getQuery(); + $params = $query->getBindValues(); + + return count($params) === 3 + && $params['id'] === $client->getId() + && $params['name'] === $client->getName() + && !empty($params['hash']) + && is_a($query, SelectInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::once()) + ->method('doQuery') + ->with($callbackDuplicate) + ->willReturn(new QueryResult([1])); + + $this->expectException(DuplicatedItemException::class); + $this->expectExceptionMessage('Duplicated client'); + + $this->clientRepository->update($client); + } + + public function testGetByName() + { + $name = self::$faker->colorName(); + + $callback = new Callback( + static function (QueryData $arg) use ($name) { + $query = $arg->getQuery(); + $params = $query->getBindValues(); + + return count($params) === 2 + && $params['name'] === $name + && !empty($params['hash']) + && $arg->getMapClassName() === Client::class + && is_a($query, SelectInterface::class) + && !empty($query->getStatement()); + } + ); + + $this->database + ->expects(self::once()) + ->method('doSelect') + ->with($callback); + + $this->clientRepository->getByName($name); + } + + protected function setUp(): void + { + parent::setUp(); + + $this->database = $this->createMock(DatabaseInterface::class); + $queryFactory = new QueryFactory('mysql'); + + $this->clientRepository = new ClientRepository( + $this->database, + $this->context, + $this->application->getEventDispatcher(), + $queryFactory, + ); + } +}