Skip to content

Commit

Permalink
psr-container-doctrine 5.2.1 support and refactoring modules configur…
Browse files Browse the repository at this point in the history
…ation

Signed-off-by: Claudiu Pintiuta <[email protected]>
  • Loading branch information
pinclau committed Jul 11, 2024
1 parent 69699c9 commit a98d381
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 25 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
24 changes: 3 additions & 21 deletions config/autoload/doctrine.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
26 changes: 26 additions & 0 deletions src/Admin/src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,13 +32,19 @@ public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),
'doctrine' => $this->getDoctrineConfig(),
MetadataMap::class => $this->getHalConfig(),
];
}

public function getDependencies(): array
{
return [
'delegators' => [
Application::class => [
RoutesDelegator::class
]
],
'factories' => [
AdminHandler::class => AttributedServiceFactory::class,
AdminAccountHandler::class => AttributedServiceFactory::class,
Expand All @@ -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 [
Expand Down
22 changes: 20 additions & 2 deletions src/App/src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,6 +48,7 @@ public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),
'doctrine' => $this->getDoctrineConfig(),
MetadataMap::class => $this->getHalConfig(),
];
}
Expand All @@ -57,8 +59,6 @@ public function getDependencies(): array
'delegators' => [
Application::class => [
RoutesDelegator::class,
\Api\Admin\RoutesDelegator::class,
\Api\User\RoutesDelegator::class,
],
],
'factories' => [
Expand Down Expand Up @@ -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 [];
Expand Down
26 changes: 26 additions & 0 deletions src/User/src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,6 +43,7 @@ public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),
'doctrine' => $this->getDoctrineConfig(),
MetadataMap::class => $this->getHalConfig(),
'templates' => $this->getTemplates(),
];
Expand All @@ -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,
Expand Down Expand Up @@ -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 [
Expand Down

0 comments on commit a98d381

Please sign in to comment.