diff --git a/composer.json b/composer.json index 9f80e96..c5358d1 100644 --- a/composer.json +++ b/composer.json @@ -53,8 +53,7 @@ "mezzio/mezzio-cors": "^1.11.1", "mezzio/mezzio-fastroute": "^3.11.0", "ramsey/uuid-doctrine": "^2.1.0", - "roave/psr-container-doctrine": "^5.1.0", - "doctrine/orm": "^3.2" + "roave/psr-container-doctrine": "^5.2.2" }, "require-dev": { "filp/whoops": "^2.15.4", diff --git a/config/autoload/doctrine.global.php b/config/autoload/doctrine.global.php index bcb1539..7207077 100644 --- a/config/autoload/doctrine.global.php +++ b/config/autoload/doctrine.global.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use Dot\Cache\Adapter\ArrayAdapter; use Dot\Cache\Adapter\FilesystemAdapter; @@ -20,6 +19,7 @@ 'metadata_cache' => 'filesystem', 'query_cache' => 'filesystem', 'hydration_cache' => 'array', + 'typed_field_mapper' => null, 'second_level_cache' => [ 'enabled' => true, 'default_lifetime' => 3600, @@ -42,14 +42,7 @@ // Override `orm_default` only if you know what you're doing 'orm_default' => [ 'class' => MappingDriverChain::class, - 'drivers' => [ - 'Frontend\\App\\Entity' => 'AppEntities', - ], - ], - 'AppEntities' => [ - 'class' => AttributeDriver::class, - 'cache' => 'array', - 'paths' => __DIR__ . '/../../src/App/src/Entity', + 'drivers' => [], ], ], 'types' => [ diff --git a/src/Admin/src/ConfigProvider.php b/src/Admin/src/ConfigProvider.php index 376d6e7..48340cb 100644 --- a/src/Admin/src/ConfigProvider.php +++ b/src/Admin/src/ConfigProvider.php @@ -22,6 +22,7 @@ use Frontend\Admin\Service\AdminServiceInterface; use Laminas\Authentication\AuthenticationService; use Laminas\Form\ElementFactory; +use Mezzio\Application; class ConfigProvider { @@ -38,6 +39,14 @@ public function __invoke(): array public function getDependencies(): array { return [ + 'delegators' => [ + Application::class => [ + RoutesDelegator::class, + ], + AdminForm::class => [ + AdminRoleDelegator::class, + ], + ], 'factories' => [ AdminController::class => AttributedServiceFactory::class, AdminService::class => AttributedServiceFactory::class, @@ -51,11 +60,6 @@ public function getDependencies(): array AdminInterface::class => Admin::class, AdminServiceInterface::class => AdminService::class, ], - 'delegators' => [ - AdminForm::class => [ - AdminRoleDelegator::class, - ], - ], ]; } diff --git a/src/App/src/ConfigProvider.php b/src/App/src/ConfigProvider.php index 532008d..e7cfab3 100644 --- a/src/App/src/ConfigProvider.php +++ b/src/App/src/ConfigProvider.php @@ -6,6 +6,7 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Dot\Controller\Factory\PluginManagerFactory; use Dot\Controller\Plugin\PluginManager; use Dot\DependencyInjection\Factory\AttributedServiceFactory; @@ -34,8 +35,6 @@ public function getDependencies(): array 'delegators' => [ Application::class => [ RoutesDelegator::class, - \Frontend\Admin\RoutesDelegator::class, - \Frontend\Setting\RoutesDelegator::class, ], ], 'factories' => [ @@ -53,6 +52,24 @@ public function getDependencies(): array ]; } + public function getDoctrineConfig(): array + { + return [ + 'driver' => [ + 'orm_default' => [ + 'drivers' => [ + 'Frontend\App\Entity' => 'AppEntities', + ], + ], + 'AppEntities' => [ + 'class' => AttributeDriver::class, + 'cache' => 'array', + 'paths' => [__DIR__ . '/Entity'], + ], + ], + ]; + } + public function getTemplates(): array { return [ diff --git a/src/Setting/src/ConfigProvider.php b/src/Setting/src/ConfigProvider.php index bfbc501..2c7da25 100644 --- a/src/Setting/src/ConfigProvider.php +++ b/src/Setting/src/ConfigProvider.php @@ -10,6 +10,7 @@ use Frontend\Setting\Controller\SettingController; use Frontend\Setting\Repository\SettingRepository; use Frontend\Setting\Service\SettingService; +use Mezzio\Application; class ConfigProvider { @@ -24,7 +25,12 @@ public function __invoke(): array public function getDependencies(): array { return [ - 'factories' => [ + 'delegators' => [ + Application::class => [ + RoutesDelegator::class, + ], + ], + 'factories' => [ SettingController::class => AttributedServiceFactory::class, SettingService::class => AttributedServiceFactory::class, SettingRepository::class => AttributedRepositoryFactory::class, diff --git a/test/Unit/App/ConfigProviderTest.php b/test/Unit/App/ConfigProviderTest.php index 66eaf50..d87c9bd 100644 --- a/test/Unit/App/ConfigProviderTest.php +++ b/test/Unit/App/ConfigProviderTest.php @@ -7,7 +7,6 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Dot\Controller\Plugin\PluginManager; -use Frontend\Admin\RoutesDelegator as AdminDelegator; use Frontend\App\ConfigProvider; use Frontend\App\Controller\DashboardController; use Frontend\App\Plugin\FormsPlugin; @@ -43,10 +42,6 @@ public function testDependenciesHasDelegators(): void $this->assertIsArray($this->config['dependencies']['delegators']); $this->assertArrayHasKey(Application::class, $this->config['dependencies']['delegators']); $this->assertIsArray($this->config['dependencies']['delegators'][Application::class]); - $this->assertContainsEquals( - AdminDelegator::class, - $this->config['dependencies']['delegators'][Application::class] - ); $this->assertContainsEquals( AppDelegator::class, $this->config['dependencies']['delegators'][Application::class]