diff --git a/composer.json b/composer.json index e8e7e0d..8fe35f6 100644 --- a/composer.json +++ b/composer.json @@ -77,8 +77,7 @@ "mezzio/mezzio-problem-details": "^1.13.1", "mezzio/mezzio-twigrenderer": "^2.15.0", "ramsey/uuid-doctrine": "^2.1.0", - "roave/psr-container-doctrine": "^5.1.0", - "doctrine/orm": "^3.2", + "roave/psr-container-doctrine": "^5.2.1", "symfony/filesystem": "^7.0.3" }, "require-dev": { diff --git a/config/autoload/doctrine.global.php b/config/autoload/doctrine.global.php index ea33c37..974f294 100644 --- a/config/autoload/doctrine.global.php +++ b/config/autoload/doctrine.global.php @@ -24,27 +24,8 @@ 'driver' => [ 'orm_default' => [ 'class' => MappingDriverChain::class, - 'drivers' => [ - 'Api\\User\\Entity' => 'UserEntities', - 'Api\\Admin\\Entity' => 'AdminEntities', - 'Api\\App\Entity' => 'AppEntities', - ], - ], - 'AdminEntities' => [ - 'class' => AttributeDriver::class, - 'cache' => 'array', - 'paths' => __DIR__ . '/../../src/Admin/src/Entity', - ], - 'UserEntities' => [ - 'class' => AttributeDriver::class, - 'cache' => 'array', - 'paths' => __DIR__ . '/../../src/User/src/Entity', - ], - 'AppEntities' => [ - 'class' => AttributeDriver::class, - 'cache' => 'array', - 'paths' => __DIR__ . '/../../src/App/src/Entity', - ], + 'drivers' => [], + ] ], 'types' => [ UuidType::NAME => UuidType::class, @@ -59,6 +40,7 @@ 'metadata_cache' => 'filesystem', 'query_cache' => 'filesystem', 'hydration_cache' => 'array', + "typed_field_mapper" => null, 'second_level_cache' => [ 'enabled' => true, 'default_lifetime' => 3600, diff --git a/src/Admin/src/ConfigProvider.php b/src/Admin/src/ConfigProvider.php index 9356e0e..c8880fe 100644 --- a/src/Admin/src/ConfigProvider.php +++ b/src/Admin/src/ConfigProvider.php @@ -20,8 +20,10 @@ use Api\Admin\Service\AdminService; use Api\Admin\Service\AdminServiceInterface; use Api\App\ConfigProvider as AppConfigProvider; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Dot\DependencyInjection\Factory\AttributedRepositoryFactory; use Dot\DependencyInjection\Factory\AttributedServiceFactory; +use Mezzio\Application; use Mezzio\Hal\Metadata\MetadataMap; class ConfigProvider @@ -30,6 +32,7 @@ public function __invoke(): array { return [ 'dependencies' => $this->getDependencies(), + 'doctrine' => $this->getDoctrineConfig(), MetadataMap::class => $this->getHalConfig(), ]; } @@ -37,6 +40,11 @@ public function __invoke(): array public function getDependencies(): array { return [ + 'delegators' => [ + Application::class => [ + RoutesDelegator::class + ] + ], 'factories' => [ AdminHandler::class => AttributedServiceFactory::class, AdminAccountHandler::class => AttributedServiceFactory::class, @@ -54,6 +62,24 @@ public function getDependencies(): array ]; } + private function getDoctrineConfig(): array + { + return [ + 'driver' => [ + 'orm_default' => [ + 'drivers' => [ + 'Api\Admin\Entity' => 'AdminEntities' + ], + ], + 'AdminEntities' => [ + 'class' => AttributeDriver::class, + 'cache' => 'array', + 'paths' => __DIR__ . '/Entity', + ], + ], + ]; + } + public function getHalConfig(): array { return [ diff --git a/src/App/src/ConfigProvider.php b/src/App/src/ConfigProvider.php index f4cd673..175cc4e 100644 --- a/src/App/src/ConfigProvider.php +++ b/src/App/src/ConfigProvider.php @@ -22,6 +22,7 @@ use Api\App\Service\ErrorReportServiceInterface; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Dot\DependencyInjection\Factory\AttributedServiceFactory; use Dot\Mail\Factory\MailOptionsAbstractFactory; use Dot\Mail\Factory\MailServiceAbstractFactory; @@ -47,6 +48,7 @@ public function __invoke(): array { return [ 'dependencies' => $this->getDependencies(), + 'doctrine' => $this->getDoctrineConfig(), MetadataMap::class => $this->getHalConfig(), ]; } @@ -57,8 +59,6 @@ public function getDependencies(): array 'delegators' => [ Application::class => [ RoutesDelegator::class, - \Api\Admin\RoutesDelegator::class, - \Api\User\RoutesDelegator::class, ], ], 'factories' => [ @@ -91,6 +91,24 @@ public function getDependencies(): array ]; } + private function getDoctrineConfig(): array + { + return [ + 'driver' => [ + 'orm_default' => [ + 'drivers' => [ + 'Api\App\Entity' => 'AppEntities' + ], + ], + 'AppEntities' => [ + 'class' => AttributeDriver::class, + 'cache' => 'array', + 'paths' => __DIR__ . '/Entity', + ], + ], + ]; + } + public function getHalConfig(): array { return []; diff --git a/src/User/src/ConfigProvider.php b/src/User/src/ConfigProvider.php index 1ad585b..8aa0147 100644 --- a/src/User/src/ConfigProvider.php +++ b/src/User/src/ConfigProvider.php @@ -31,8 +31,10 @@ use Api\User\Service\UserRoleServiceInterface; use Api\User\Service\UserService; use Api\User\Service\UserServiceInterface; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Dot\DependencyInjection\Factory\AttributedRepositoryFactory; use Dot\DependencyInjection\Factory\AttributedServiceFactory; +use Mezzio\Application; use Mezzio\Hal\Metadata\MetadataMap; class ConfigProvider @@ -41,6 +43,7 @@ public function __invoke(): array { return [ 'dependencies' => $this->getDependencies(), + 'doctrine' => $this->getDoctrineConfig(), MetadataMap::class => $this->getHalConfig(), 'templates' => $this->getTemplates(), ]; @@ -49,6 +52,11 @@ public function __invoke(): array public function getDependencies(): array { return [ + 'delegators' => [ + Application::class => [ + RoutesDelegator::class, + ] + ], 'factories' => [ AccountActivateHandler::class => AttributedServiceFactory::class, AccountAvatarHandler::class => AttributedServiceFactory::class, @@ -77,6 +85,24 @@ public function getDependencies(): array ]; } + private function getDoctrineConfig(): array + { + return [ + 'driver' => [ + 'orm_default' => [ + 'drivers' => [ + 'Api\User\Entity' => 'UserEntities' + ], + ], + 'UserEntities' => [ + 'class' => AttributeDriver::class, + 'cache' => 'array', + 'paths' => __DIR__ . '/Entity', + ], + ], + ]; + } + public function getHalConfig(): array { return [