Skip to content

Commit

Permalink
fix: change entitymanager to abstraction interface
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielberthier committed Jun 8, 2023
1 parent 1383b33 commit 124cb39
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 40 deletions.
3 changes: 2 additions & 1 deletion app/Data/Doctrine/EntityManagerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\ORMSetup;

class EntityManagerBuilder
{
public static function produce(array $doctrine): EntityManager
public static function produce(array $doctrine): EntityManagerInterface
{
$devMode = $doctrine['dev_mode'];

Expand Down
14 changes: 0 additions & 14 deletions app/Definitions/cycleconnections.php

This file was deleted.

30 changes: 17 additions & 13 deletions app/Definitions/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Monolog\Logger;
use Psr\Container\ContainerInterface;

return [
'settings' => [
Expand All @@ -12,18 +13,21 @@
'path' => isset($_ENV['docker']) ? 'php://stdout' : __DIR__.'/../logs/app.log',
'level' => Logger::DEBUG,
],
'doctrine' => [
// if true, metadata caching is forcefully disabled
'dev_mode' => true,

// path where the compiled metadata info will be cached
// make sure the path exists and it is writable
'cache_dir' => getcwd().'/var/doctrine',

// you should add any other path containing annotated entity classes
'metadata_dirs' => [getcwd().'/src/Domain/Models'],

'connection' => require __DIR__.'/connection.php',
],
'doctrine' => static function (ContainerInterface $c): array {
$devMode = $c->get("environment") === "DEV";
return [
// if true, metadata caching is forcefully disabled
'dev_mode' => $devMode,

// path where the compiled metadata info will be cached
// make sure the path exists and it is writable
'cache_dir' => getcwd().'/var/doctrine',

// you should add any other path containing annotated entity classes
'metadata_dirs' => [getcwd().'/src/Domain/Models'],

'connection' => $c->get('connection'),
];
}
],
];
2 changes: 1 addition & 1 deletion cli-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager;
use Doctrine\Migrations\Configuration\Migration\PhpFile;
use Doctrine\Migrations\DependencyFactory;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;

require __DIR__ . '/configs/bootstrap.php';

Expand Down
2 changes: 1 addition & 1 deletion src/Data/UseCases/Markers/MarkerServiceStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use App\Domain\Models\Marker\Marker;
use App\Domain\Repositories\MarkerRepositoryInterface;
use App\Domain\Repositories\MuseumRepository;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;
use Exception;

class MarkerServiceStore implements MarkerServiceStoreInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use App\Domain\Repositories\PersistenceOperations\CrudOperationsInterface;
use App\Domain\Repositories\PersistenceOperations\Responses\ResultSetInterface;
use App\Infrastructure\Persistence\PersistenceUtils\ItemsRetriever;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;
use Doctrine\Persistence\ObjectRepository;

abstract class AbstractRepository implements CrudOperationsInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Domain\Models\Enums\AuthTypes;
use App\Domain\Repositories\AccountRepository;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;

class DoctrineAccountRepository implements AccountRepository
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Domain\Repositories\PersistenceOperations\Responses\ResultSetInterface;
use App\Domain\Repositories\PersistenceOperations\Responses\SearchResult;
use App\Infrastructure\Persistence\Pagination\PaginationService;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;

class ItemsRetriever
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Domain\Repositories\SignatureTokenRepositoryInterface;
use App\Domain\Repositories\SignatureTokenRetrieverInterface;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;

class SignatureTokenRepository implements SignatureTokenRepositoryInterface, SignatureTokenRetrieverInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use App\Domain\Repositories\MarkerRepositoryInterface;
use App\Domain\Repositories\MuseumRepository;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;
use PHPUnit\Framework\MockObject\MockObject;
use Prophecy\PhpUnit\ProphecyTrait;
use Tests\TestCase;
Expand Down
2 changes: 1 addition & 1 deletion tests/Domain/UseCases/Markers/Store/SutTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use App\Data\UseCases\Markers\MarkerServiceStore;
use App\Domain\Repositories\MarkerRepositoryInterface;
use App\Domain\Repositories\MuseumRepository;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;

class SutTypes
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Domain\Dto\AccountDto;
use App\Domain\Models\Account;
use App\Domain\Repositories\AccountRepository;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;
use function PHPUnit\Framework\assertInstanceOf;
use function PHPUnit\Framework\assertSame;
use Tests\TestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Tests\Infrastructure\Persistence\Orm;

use DI\Container;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;
use Tests\TestCase;

use function PHPUnit\Framework\assertArrayHasKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use App\Domain\Models\Marker\MarkerAsset;
use App\Domain\Models\PlacementObject\PlacementObject;
use App\Domain\Repositories\MarkerRepositoryInterface;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;
use function PHPUnit\Framework\assertInstanceOf;
use function PHPUnit\Framework\assertSame;
use Tests\TestCase;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Tests;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface as EntityManager;
use Doctrine\ORM\Tools\SchemaTool;
use PHPUnit\Framework\TestCase as PHPUnit_TestCase;
use Tests\Traits\App\AppTestTrait;
Expand Down

0 comments on commit 124cb39

Please sign in to comment.