diff --git a/Application/Service/DataGateway.php b/Application/Service/DataGateway.php old mode 100755 new mode 100644 index 07b585e..3212ecb --- a/Application/Service/DataGateway.php +++ b/Application/Service/DataGateway.php @@ -3,11 +3,12 @@ namespace Ivoz\Core\Application\Service; use Doctrine\ORM\EntityManagerInterface; -use Ivoz\Core\Application\DataTransferObjectInterface; -use Ivoz\Core\Application\Event\CommandWasExecuted; -use Ivoz\Core\Application\RequestId; -use Ivoz\Core\Application\Service\Assembler\DtoAssembler; +use Ivoz\Core\Domain\DataTransferObjectInterface; +use Ivoz\Core\Domain\Event\CommandWasExecuted; +use Ivoz\Core\Domain\RequestId; +use Ivoz\Core\Domain\Service\Assembler\DtoAssembler; use Ivoz\Core\Domain\Service\DomainEventPublisher; +use Ivoz\Core\Domain\Service\QueryBuilderFactory; use Ivoz\Core\Infrastructure\Domain\Service\DoctrineEntityPersister; /** @@ -52,9 +53,6 @@ class DataGateway */ public static $user = ''; - /** - * DataGateway constructor. - */ public function __construct( EntityManagerInterface $entityManager, QueryBuilderFactory $queryBuilderFactory, diff --git a/Application/DataTransferObjectInterface.php b/Domain/DataTransferObjectInterface.php similarity index 97% rename from Application/DataTransferObjectInterface.php rename to Domain/DataTransferObjectInterface.php index 33c19e1..1d34983 100755 --- a/Application/DataTransferObjectInterface.php +++ b/Domain/DataTransferObjectInterface.php @@ -1,6 +1,6 @@ em = $em; + public function __construct( + private EntityManagerInterface $em + ) { } /** diff --git a/Infrastructure/Domain/Service/Cgrates/FakeCgrRpcClient.php b/Infrastructure/Domain/Service/Cgrates/FakeCgrRpcClient.php index 284e24e..cb579e4 100644 --- a/Infrastructure/Domain/Service/Cgrates/FakeCgrRpcClient.php +++ b/Infrastructure/Domain/Service/Cgrates/FakeCgrRpcClient.php @@ -10,7 +10,6 @@ class FakeCgrRpcClient implements ClientInterface { - private $fixedResponse = '{"error": null}'; public function __construct( @@ -30,7 +29,7 @@ public function request($id, $method, array $params = null) 'POST', '/uri', [], - '[]' + $this->fixedResponse ); } @@ -39,7 +38,7 @@ public function send(RequestInterface $request) return new Response( 200, [], - $this->fixedResponse + '{"error": null}' ); } diff --git a/Infrastructure/Domain/Service/DoctrineEntityPersister.php b/Infrastructure/Domain/Service/DoctrineEntityPersister.php index 4d8d8f7..8e79541 100755 --- a/Infrastructure/Domain/Service/DoctrineEntityPersister.php +++ b/Infrastructure/Domain/Service/DoctrineEntityPersister.php @@ -5,10 +5,10 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\UnitOfWork; -use Ivoz\Core\Application\DataTransferObjectInterface; -use Ivoz\Core\Application\Helper\EntityClassHelper; -use Ivoz\Core\Application\Service\CreateEntityFromDto; -use Ivoz\Core\Application\Service\UpdateEntityFromDto; +use Ivoz\Core\Domain\DataTransferObjectInterface; +use Ivoz\Core\Domain\Helper\EntityClassHelper; +use Ivoz\Core\Domain\Service\CreateEntityFromDto; +use Ivoz\Core\Domain\Service\UpdateEntityFromDto; use Ivoz\Core\Domain\Model\EntityInterface; use Ivoz\Core\Domain\Service\EntityPersisterInterface; use Ivoz\Core\Infrastructure\Persistence\Doctrine\Events as CustomEvents; diff --git a/Infrastructure/Domain/Service/Lifecycle/CommandPersister.php b/Infrastructure/Domain/Service/Lifecycle/CommandPersister.php index e545c5a..f0e0d1a 100755 --- a/Infrastructure/Domain/Service/Lifecycle/CommandPersister.php +++ b/Infrastructure/Domain/Service/Lifecycle/CommandPersister.php @@ -2,8 +2,8 @@ namespace Ivoz\Core\Infrastructure\Domain\Service\Lifecycle; -use Ivoz\Core\Application\Event\CommandWasExecuted; -use Ivoz\Core\Application\Service\CommandEventSubscriber; +use Ivoz\Core\Domain\Event\CommandWasExecuted; +use Ivoz\Core\Domain\Service\CommandEventSubscriber; use Ivoz\Core\Domain\Event\EntityEventInterface; use Ivoz\Core\Domain\Service\EntityEventSubscriber; use Ivoz\Core\Domain\Service\EntityPersisterInterface; diff --git a/Infrastructure/Domain/Service/Lifecycle/DoctrineEventSubscriber.php b/Infrastructure/Domain/Service/Lifecycle/DoctrineEventSubscriber.php index 4771d33..f9a17e9 100755 --- a/Infrastructure/Domain/Service/Lifecycle/DoctrineEventSubscriber.php +++ b/Infrastructure/Domain/Service/Lifecycle/DoctrineEventSubscriber.php @@ -12,7 +12,7 @@ use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; use Doctrine\ORM\Tools\ToolEvents; use Doctrine\Persistence\Event\LifecycleEventArgs; -use Ivoz\Core\Application\Helper\{EntityClassHelper, LifecycleServiceHelper,}; +use Ivoz\Core\Domain\Helper\{EntityClassHelper, LifecycleServiceHelper,}; use Ivoz\Core\Domain\Event\{EntityWasCreated, EntityWasDeleted, EntityWasUpdated,}; use Ivoz\Core\Domain\Model\{EntityInterface, LoggableEntityInterface, LoggerEntityInterface,}; use Ivoz\Core\Domain\Service\{CommonLifecycleServiceCollection, DomainEventPublisher,}; diff --git a/Infrastructure/Persistence/Doctrine/Hydration/DtoHydrator.php b/Infrastructure/Persistence/Doctrine/Hydration/DtoHydrator.php index 13a65a8..7979b74 100644 --- a/Infrastructure/Persistence/Doctrine/Hydration/DtoHydrator.php +++ b/Infrastructure/Persistence/Doctrine/Hydration/DtoHydrator.php @@ -2,7 +2,10 @@ namespace Ivoz\Core\Infrastructure\Persistence\Doctrine\Hydration; +use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ArrayHydrator; +use Doctrine\ORM\Internal\Hydration\IterableResult; +use Doctrine\ORM\Query\ResultSetMapping; use Ivoz\Core\Domain\Model\EntityInterface; class DtoHydrator extends ArrayHydrator @@ -10,7 +13,15 @@ class DtoHydrator extends ArrayHydrator protected $loadedEntities = []; /** - * {@inheritdoc} + * Initiates a row-by-row hydration. + * + * @deprecated + * + * @param Result $stmt + * @param ResultSetMapping $resultSetMapping + * @psalm-param array $hints + * + * @return IterableResult|array */ public function hydrateAll($stmt, $resultSetMapping, array $hints = array()) { @@ -36,7 +47,7 @@ public function hydrateRow() ); } - private function mapToDto(array $rows) + private function mapToDto(array $rows): array { $aliasMap = $this->_rsm->getAliasMap(); diff --git a/Infrastructure/Persistence/Doctrine/LoggableMigration.php b/Infrastructure/Persistence/Doctrine/LoggableMigration.php index ed7c551..4907ef8 100644 --- a/Infrastructure/Persistence/Doctrine/LoggableMigration.php +++ b/Infrastructure/Persistence/Doctrine/LoggableMigration.php @@ -4,7 +4,7 @@ use Doctrine\Migrations\AbstractMigration;; use Doctrine\DBAL\Schema\Schema; -use Ivoz\Core\Application\Event\CommandWasExecuted; +use Ivoz\Core\Domain\Event\CommandWasExecuted; use Ivoz\Core\Domain\Event\EntityWasUpdated; use Ivoz\Core\Domain\Model\Changelog\Changelog; use Ivoz\Core\Domain\Model\Commandlog\Commandlog; diff --git a/Infrastructure/Persistence/Doctrine/Model/DBAL/Types/UtcDateTimeType.php b/Infrastructure/Persistence/Doctrine/Model/DBAL/Types/UtcDateTimeType.php index a41ea96..539276e 100755 --- a/Infrastructure/Persistence/Doctrine/Model/DBAL/Types/UtcDateTimeType.php +++ b/Infrastructure/Persistence/Doctrine/Model/DBAL/Types/UtcDateTimeType.php @@ -10,7 +10,10 @@ class UtcDateTimeType extends DateTimeType { static private $utc; - public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed + /** + * {@inheritdoc} + */ + public function convertToDatabaseValue($value, AbstractPlatform $platform) { if (is_string($value)) { return $value; @@ -50,4 +53,4 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $converted; } -} +} \ No newline at end of file diff --git a/Infrastructure/Persistence/Doctrine/ORM/EntityManager.php b/Infrastructure/Persistence/Doctrine/ORM/EntityManager.php index 1749c0a..17b65a6 100755 --- a/Infrastructure/Persistence/Doctrine/ORM/EntityManager.php +++ b/Infrastructure/Persistence/Doctrine/ORM/EntityManager.php @@ -152,4 +152,4 @@ public function createQueryBuilder() { return new QueryBuilder($this); } -} +} \ No newline at end of file diff --git a/Infrastructure/Persistence/Filesystem/ScheduleForRemove.php b/Infrastructure/Persistence/Filesystem/ScheduleForRemove.php index bc93a36..a74fe7d 100644 --- a/Infrastructure/Persistence/Filesystem/ScheduleForRemove.php +++ b/Infrastructure/Persistence/Filesystem/ScheduleForRemove.php @@ -2,7 +2,7 @@ namespace Ivoz\Core\Infrastructure\Persistence\Filesystem; -use Ivoz\Core\Application\Service\StoragePathResolverCollection; +use Ivoz\Core\Domain\Service\StoragePathResolverCollection; use Ivoz\Core\Domain\Model\EntityInterface; use Ivoz\Core\Domain\Service\CommonLifecycleEventHandlerInterface; use Ivoz\Core\Domain\Service\FileContainerInterface; diff --git a/Infrastructure/Persistence/Redis/Lock.php b/Infrastructure/Persistence/Redis/Lock.php index 1362360..fa536b0 100644 --- a/Infrastructure/Persistence/Redis/Lock.php +++ b/Infrastructure/Persistence/Redis/Lock.php @@ -2,7 +2,7 @@ namespace Ivoz\Core\Infrastructure\Persistence\Redis; -use Ivoz\Core\Application\MutexInterface; +use Ivoz\Core\Domain\MutexInterface; use Psr\Log\LoggerInterface; class Lock implements MutexInterface diff --git a/Infrastructure/Service/Rest/Client.php b/Infrastructure/Service/Rest/Client.php deleted file mode 100644 index 25e213b..0000000 --- a/Infrastructure/Service/Rest/Client.php +++ /dev/null @@ -1,139 +0,0 @@ -httpClient = $platformHttpClient; - $this->jwtTokenManager = $jwtTokenManager; - $this->administratorRepository = $administratorRepository; - - $privateAdmin = $this->administratorRepository->getInnerGlobalAdmin(); - $this->jwtToken = $this->jwtTokenManager->create( - $privateAdmin - ); - } - - /** - * @param string $uri - * @param array $options - * @return ResponseInterface - */ - public function get(string $uri, array $options = []) - { - $options = $this->appendAuthHeaders($options); - - return $this->request( - 'GET', - $uri, - $options - ); - } - - /** - * @param string $uri - * @param array $options - * @return ResponseInterface - */ - public function post(string $uri, array $options = []) - { - $options = $this->appendAuthHeaders($options); - - return $this->request( - 'POST', - $uri, - $options - ); - } - - /** - * @param string $uri - * @param array $options - * @return ResponseInterface - */ - public function put(string $uri, array $options = []) - { - $options = $this->appendAuthHeaders($options); - - return $this->request( - 'PUT', - $uri, - $options - ); - } - - /** - * @param string $uri - * @param array $options - * @return ResponseInterface - */ - public function delete(string $uri, array $options = []) - { - $options = $this->appendAuthHeaders($options); - - return $this->request( - 'DELETE', - $uri, - $options - ); - } - - /** - * - * @param string $method HTTP method. - * @param string|UriInterface $uri URI object or string. - * @param array $options Request options to apply. - * - * @return ResponseInterface - * @throws \RuntimeException - */ - protected function request($method, $uri = '', array $options = []) - { - try { - return $this->httpClient->request( - $method, - $uri, - $options - ); - } catch (\Exception $e) { - throw new \RuntimeException( - $e->getMessage(), - $e->getCode(), - $e - ); - } - } - - /** - * @return array - * - * @psalm-return array{"headers":empty, headers:array{Authorization:string}} - */ - private function appendAuthHeaders(array $options): array - { - if (!array_key_exists('headers', $options)) { - $options['headers'] = []; - } - $options['headers']['Authorization'] = 'Bearer ' . $this->jwtToken; - - return $options; - } -} diff --git a/Infrastructure/Service/Rest/FakeClient.php b/Infrastructure/Service/Rest/FakeClient.php deleted file mode 100644 index fd26e33..0000000 --- a/Infrastructure/Service/Rest/FakeClient.php +++ /dev/null @@ -1,47 +0,0 @@ -