Skip to content

Commit

Permalink
Merge pull request #263 from dotkernel/issue-262
Browse files Browse the repository at this point in the history
bump psr-container-doctrine and refactoring config providers
  • Loading branch information
arhimede authored Jul 15, 2024
2 parents bfd6b82 + f9ad147 commit 975245a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 24 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 2 additions & 9 deletions config/autoload/doctrine.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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' => [
Expand Down
14 changes: 9 additions & 5 deletions src/Admin/src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Frontend\Admin\Service\AdminServiceInterface;
use Laminas\Authentication\AuthenticationService;
use Laminas\Form\ElementFactory;
use Mezzio\Application;

class ConfigProvider
{
Expand All @@ -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,
Expand All @@ -51,11 +60,6 @@ public function getDependencies(): array
AdminInterface::class => Admin::class,
AdminServiceInterface::class => AdminService::class,
],
'delegators' => [
AdminForm::class => [
AdminRoleDelegator::class,
],
],
];
}

Expand Down
21 changes: 19 additions & 2 deletions src/App/src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -34,8 +35,6 @@ public function getDependencies(): array
'delegators' => [
Application::class => [
RoutesDelegator::class,
\Frontend\Admin\RoutesDelegator::class,
\Frontend\Setting\RoutesDelegator::class,
],
],
'factories' => [
Expand All @@ -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 [
Expand Down
8 changes: 7 additions & 1 deletion src/Setting/src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Frontend\Setting\Controller\SettingController;
use Frontend\Setting\Repository\SettingRepository;
use Frontend\Setting\Service\SettingService;
use Mezzio\Application;

class ConfigProvider
{
Expand All @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions test/Unit/App/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 975245a

Please sign in to comment.