Skip to content

Commit 975245a

Browse files
authored
Merge pull request #263 from dotkernel/issue-262
bump psr-container-doctrine and refactoring config providers
2 parents bfd6b82 + f9ad147 commit 975245a

File tree

6 files changed

+38
-24
lines changed

6 files changed

+38
-24
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
"mezzio/mezzio-cors": "^1.11.1",
5454
"mezzio/mezzio-fastroute": "^3.11.0",
5555
"ramsey/uuid-doctrine": "^2.1.0",
56-
"roave/psr-container-doctrine": "^5.1.0",
57-
"doctrine/orm": "^3.2"
56+
"roave/psr-container-doctrine": "^5.2.2"
5857
},
5958
"require-dev": {
6059
"filp/whoops": "^2.15.4",

config/autoload/doctrine.global.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
declare(strict_types=1);
44

5-
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
65
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
76
use Dot\Cache\Adapter\ArrayAdapter;
87
use Dot\Cache\Adapter\FilesystemAdapter;
@@ -20,6 +19,7 @@
2019
'metadata_cache' => 'filesystem',
2120
'query_cache' => 'filesystem',
2221
'hydration_cache' => 'array',
22+
'typed_field_mapper' => null,
2323
'second_level_cache' => [
2424
'enabled' => true,
2525
'default_lifetime' => 3600,
@@ -42,14 +42,7 @@
4242
// Override `orm_default` only if you know what you're doing
4343
'orm_default' => [
4444
'class' => MappingDriverChain::class,
45-
'drivers' => [
46-
'Frontend\\App\\Entity' => 'AppEntities',
47-
],
48-
],
49-
'AppEntities' => [
50-
'class' => AttributeDriver::class,
51-
'cache' => 'array',
52-
'paths' => __DIR__ . '/../../src/App/src/Entity',
45+
'drivers' => [],
5346
],
5447
],
5548
'types' => [

src/Admin/src/ConfigProvider.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Frontend\Admin\Service\AdminServiceInterface;
2323
use Laminas\Authentication\AuthenticationService;
2424
use Laminas\Form\ElementFactory;
25+
use Mezzio\Application;
2526

2627
class ConfigProvider
2728
{
@@ -38,6 +39,14 @@ public function __invoke(): array
3839
public function getDependencies(): array
3940
{
4041
return [
42+
'delegators' => [
43+
Application::class => [
44+
RoutesDelegator::class,
45+
],
46+
AdminForm::class => [
47+
AdminRoleDelegator::class,
48+
],
49+
],
4150
'factories' => [
4251
AdminController::class => AttributedServiceFactory::class,
4352
AdminService::class => AttributedServiceFactory::class,
@@ -51,11 +60,6 @@ public function getDependencies(): array
5160
AdminInterface::class => Admin::class,
5261
AdminServiceInterface::class => AdminService::class,
5362
],
54-
'delegators' => [
55-
AdminForm::class => [
56-
AdminRoleDelegator::class,
57-
],
58-
],
5963
];
6064
}
6165

src/App/src/ConfigProvider.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Doctrine\ORM\EntityManager;
88
use Doctrine\ORM\EntityManagerInterface;
9+
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
910
use Dot\Controller\Factory\PluginManagerFactory;
1011
use Dot\Controller\Plugin\PluginManager;
1112
use Dot\DependencyInjection\Factory\AttributedServiceFactory;
@@ -34,8 +35,6 @@ public function getDependencies(): array
3435
'delegators' => [
3536
Application::class => [
3637
RoutesDelegator::class,
37-
\Frontend\Admin\RoutesDelegator::class,
38-
\Frontend\Setting\RoutesDelegator::class,
3938
],
4039
],
4140
'factories' => [
@@ -53,6 +52,24 @@ public function getDependencies(): array
5352
];
5453
}
5554

55+
public function getDoctrineConfig(): array
56+
{
57+
return [
58+
'driver' => [
59+
'orm_default' => [
60+
'drivers' => [
61+
'Frontend\App\Entity' => 'AppEntities',
62+
],
63+
],
64+
'AppEntities' => [
65+
'class' => AttributeDriver::class,
66+
'cache' => 'array',
67+
'paths' => [__DIR__ . '/Entity'],
68+
],
69+
],
70+
];
71+
}
72+
5673
public function getTemplates(): array
5774
{
5875
return [

src/Setting/src/ConfigProvider.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Frontend\Setting\Controller\SettingController;
1111
use Frontend\Setting\Repository\SettingRepository;
1212
use Frontend\Setting\Service\SettingService;
13+
use Mezzio\Application;
1314

1415
class ConfigProvider
1516
{
@@ -24,7 +25,12 @@ public function __invoke(): array
2425
public function getDependencies(): array
2526
{
2627
return [
27-
'factories' => [
28+
'delegators' => [
29+
Application::class => [
30+
RoutesDelegator::class,
31+
],
32+
],
33+
'factories' => [
2834
SettingController::class => AttributedServiceFactory::class,
2935
SettingService::class => AttributedServiceFactory::class,
3036
SettingRepository::class => AttributedRepositoryFactory::class,

test/Unit/App/ConfigProviderTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Doctrine\ORM\EntityManager;
88
use Doctrine\ORM\EntityManagerInterface;
99
use Dot\Controller\Plugin\PluginManager;
10-
use Frontend\Admin\RoutesDelegator as AdminDelegator;
1110
use Frontend\App\ConfigProvider;
1211
use Frontend\App\Controller\DashboardController;
1312
use Frontend\App\Plugin\FormsPlugin;
@@ -43,10 +42,6 @@ public function testDependenciesHasDelegators(): void
4342
$this->assertIsArray($this->config['dependencies']['delegators']);
4443
$this->assertArrayHasKey(Application::class, $this->config['dependencies']['delegators']);
4544
$this->assertIsArray($this->config['dependencies']['delegators'][Application::class]);
46-
$this->assertContainsEquals(
47-
AdminDelegator::class,
48-
$this->config['dependencies']['delegators'][Application::class]
49-
);
5045
$this->assertContainsEquals(
5146
AppDelegator::class,
5247
$this->config['dependencies']['delegators'][Application::class]

0 commit comments

Comments
 (0)