From 9c883452ef490501596d68297154dd3b4895dd24 Mon Sep 17 00:00:00 2001 From: lucianoqueiroz Date: Sat, 4 Mar 2017 18:34:06 -0300 Subject: [PATCH 01/11] moving logic from named constructor to private constructor --- .../Domain/Command/CreateConference.php | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/Conference/Domain/Command/CreateConference.php b/src/Conference/Domain/Command/CreateConference.php index 8f56d94..7c881fb 100644 --- a/src/Conference/Domain/Command/CreateConference.php +++ b/src/Conference/Domain/Command/CreateConference.php @@ -54,30 +54,39 @@ final class CreateConference extends Command */ private $date; - private function __construct() - { - } - - public static function fromRequestData( + private function __construct( ConferenceId $conferenceId, string $name, string $description, string $author, \DateTimeImmutable $date - ): self { - // @todo move to __constructor + ) + { Assertion::notEmpty($name); Assertion::notEmpty($description); Assertion::notEmpty($author); - $self = new self(); - $self->conferenceId = $conferenceId; - $self->name = $name; - $self->description = $description; - $self->author = $author; - $self->date = $date; + $this->conferenceId = $conferenceId; + $this->name = $name; + $this->description = $description; + $this->author = $author; + $this->date = $date; + } - return $self; + public static function fromRequestData( + ConferenceId $conferenceId, + string $name, + string $description, + string $author, + \DateTimeImmutable $date + ): self { + return new self( + $conferenceId, + $name, + $description, + $author, + $date + ); } /** From e26062a1ccdf35223d142833fedf0903d3095c12 Mon Sep 17 00:00:00 2001 From: lucianoqueiroz Date: Sat, 4 Mar 2017 18:36:18 -0300 Subject: [PATCH 02/11] fixing cs --- src/Conference/Domain/Command/CreateConference.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Conference/Domain/Command/CreateConference.php b/src/Conference/Domain/Command/CreateConference.php index 7c881fb..f8f6842 100644 --- a/src/Conference/Domain/Command/CreateConference.php +++ b/src/Conference/Domain/Command/CreateConference.php @@ -60,8 +60,7 @@ private function __construct( string $description, string $author, \DateTimeImmutable $date - ) - { + ) { Assertion::notEmpty($name); Assertion::notEmpty($description); Assertion::notEmpty($author); From c2038cc03473ca582cf9b05336acf9b3012acd8f Mon Sep 17 00:00:00 2001 From: lucianoqueiroz Date: Sat, 4 Mar 2017 20:47:54 -0300 Subject: [PATCH 03/11] creating new config files and application factory --- config/commands.php | 14 ++++++++ config/repositories.php | 14 ++++++++ config/service-manager.php | 6 ++-- config/services.php | 17 ++------- .../Service/ApplicationFactory.php | 36 +++++++++++++++++++ 5 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 config/commands.php create mode 100644 config/repositories.php create mode 100644 src/Conference/Infrastructure/Service/ApplicationFactory.php diff --git a/config/commands.php b/config/commands.php new file mode 100644 index 0000000..5db7842 --- /dev/null +++ b/config/commands.php @@ -0,0 +1,14 @@ + [ + CreateConference::class => CreateConferenceHandlerFactory::class, + ], + ]; +})(); diff --git a/config/repositories.php b/config/repositories.php new file mode 100644 index 0000000..e43f022 --- /dev/null +++ b/config/repositories.php @@ -0,0 +1,14 @@ + [ + ConferenceRepositoryInterface::class => ConferenceRepositoryFactory::class, + ], + ]; +})(); diff --git a/config/service-manager.php b/config/service-manager.php index 94570cd..308e6f4 100644 --- a/config/service-manager.php +++ b/config/service-manager.php @@ -7,8 +7,10 @@ return (function () { return new \Zend\ServiceManager\ServiceManager( array_merge_recursive( - require __DIR__ . '/services.php', - require __DIR__ . '/middlewares.php' + require __DIR__ . '/commands.php', + require __DIR__ . '/middlewares.php', + require __DIR__ . '/repositories.php', + require __DIR__ . '/services.php' ) ); })(); diff --git a/config/services.php b/config/services.php index 57c9347..4b99fba 100644 --- a/config/services.php +++ b/config/services.php @@ -2,13 +2,10 @@ declare(strict_types=1); -use Conticket\Conference\Domain\Repository\ConferenceRepositoryInterface; -use Conticket\Conference\Factory\Repository\ConferenceRepositoryFactory; -use Conticket\Conference\Factory\CommandHandler\CreateConferenceHandlerFactory; -use Conticket\Conference\Domain\Command\CreateConference; use Conticket\Conference\Infrastructure\Service\CommandBusFactory; use Conticket\Conference\Infrastructure\Service\ConnectionFactory; use Conticket\Conference\Infrastructure\Service\EventStoreFactory; +use Conticket\Conference\Infrastructure\Service\ApplicationFactory; use Doctrine\DBAL\Connection; use Interop\Container\ContainerInterface; use Prooph\EventStore\EventStore; @@ -20,9 +17,7 @@ return [ // @todo move factories to proper classes 'factories' => [ - Application::class => function (ContainerInterface $container) { - return new Application($container->get(FastRouteRouter::class), $container); - }, + Application::class => ApplicationFactory::class, FastRouteRouter::class => function (ContainerInterface $container) { return new FastRouteRouter(); }, @@ -31,12 +26,6 @@ EventStore::class => EventStoreFactory::class, Connection::class => ConnectionFactory::class, - // @todo move commands/events to another config file - CreateConference::class => CreateConferenceHandlerFactory::class, - - // @todo move repository to another file - ConferenceRepositoryInterface::class => ConferenceRepositoryFactory::class, - // @todo move db info to a class to get ENV vars 'db_dsn' => function () { return 'mysql:host=localhost;dbname=conticket'; @@ -45,7 +34,7 @@ return 'root'; }, 'db_password' => function () { - return 'root'; + return null; }, ], ]; diff --git a/src/Conference/Infrastructure/Service/ApplicationFactory.php b/src/Conference/Infrastructure/Service/ApplicationFactory.php new file mode 100644 index 0000000..fd8e5c5 --- /dev/null +++ b/src/Conference/Infrastructure/Service/ApplicationFactory.php @@ -0,0 +1,36 @@ + + */ +final class ApplicationFactory +{ + public function __invoke(ContainerInterface $container): Application + { + return new Application($container->get(FastRouteRouter::class), $container); + } +} \ No newline at end of file From 52b48a6b08fd01ec69e72ee553870c83391ffaf4 Mon Sep 17 00:00:00 2001 From: lucianoqueiroz Date: Sat, 4 Mar 2017 20:59:30 -0300 Subject: [PATCH 04/11] creating router factory --- config/services.php | 9 ++--- .../Infrastructure/Service/RouterFactory.php | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 src/Conference/Infrastructure/Service/RouterFactory.php diff --git a/config/services.php b/config/services.php index 4b99fba..f0efdd8 100644 --- a/config/services.php +++ b/config/services.php @@ -6,22 +6,19 @@ use Conticket\Conference\Infrastructure\Service\ConnectionFactory; use Conticket\Conference\Infrastructure\Service\EventStoreFactory; use Conticket\Conference\Infrastructure\Service\ApplicationFactory; +use Conticket\Conference\Infrastructure\Service\RouterFactory; use Doctrine\DBAL\Connection; -use Interop\Container\ContainerInterface; use Prooph\EventStore\EventStore; use Prooph\ServiceBus\CommandBus; use Zend\Expressive\Application; use Zend\Expressive\Router\FastRouteRouter; + return (function () { return [ - // @todo move factories to proper classes 'factories' => [ Application::class => ApplicationFactory::class, - FastRouteRouter::class => function (ContainerInterface $container) { - return new FastRouteRouter(); - }, - + FastRouteRouter::class => RouterFactory::class, CommandBus::class => CommandBusFactory::class, EventStore::class => EventStoreFactory::class, Connection::class => ConnectionFactory::class, diff --git a/src/Conference/Infrastructure/Service/RouterFactory.php b/src/Conference/Infrastructure/Service/RouterFactory.php new file mode 100644 index 0000000..a6634ca --- /dev/null +++ b/src/Conference/Infrastructure/Service/RouterFactory.php @@ -0,0 +1,36 @@ + + */ +final class RouterFactory +{ + public function __invoke(ContainerInterface $container): FastRouteRouter + { + return new FastRouteRouter(); + } +} \ No newline at end of file From cbb39f02d7c2b07158b3550a0356cb5d2fede5b0 Mon Sep 17 00:00:00 2001 From: lucianoqueiroz Date: Sun, 5 Mar 2017 09:35:35 -0300 Subject: [PATCH 05/11] removing router factory, fixing cs in application factory and adding dotenv package --- .env.example | 3 ++ .gitignore | 1 + composer.json | 3 +- config/services.php | 15 ++------ public/index.php | 3 ++ .../Domain/Command/CreateConference.php | 8 +---- .../Service/ApplicationFactory.php | 2 +- .../Service/ConnectionFactory.php | 6 ++-- .../Infrastructure/Service/RouterFactory.php | 36 ------------------- 9 files changed, 16 insertions(+), 61 deletions(-) create mode 100644 .env.example delete mode 100644 src/Conference/Infrastructure/Service/RouterFactory.php diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..4985192 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +DB_DSN=mysql:host=localhost;dbname=conticket +DB_USER=root +DB_PASSWORD= \ No newline at end of file diff --git a/.gitignore b/.gitignore index b2a0a49..8379cb4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ composer.phar composer.lock bin vendor/ +.env app/cache/* app/logs/* app/phpunit.xml diff --git a/composer.json b/composer.json index e23eb6f..dd8d69e 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,8 @@ "ramsey/uuid": "^2.8", "zendframework/zend-expressive": "^1.0", "zendframework/zend-expressive-fastroute": "^1.0", - "zendframework/zend-servicemanager": "^3.2" + "zendframework/zend-servicemanager": "^3.2", + "vlucas/phpdotenv": "^2.4" }, "require-dev": { "behat/behat": "3.*@stable", diff --git a/config/services.php b/config/services.php index f0efdd8..7fc3e89 100644 --- a/config/services.php +++ b/config/services.php @@ -12,27 +12,16 @@ use Prooph\ServiceBus\CommandBus; use Zend\Expressive\Application; use Zend\Expressive\Router\FastRouteRouter; - +use Zend\ServiceManager\Factory\InvokableFactory; return (function () { return [ 'factories' => [ Application::class => ApplicationFactory::class, - FastRouteRouter::class => RouterFactory::class, + FastRouteRouter::class => InvokableFactory::class, CommandBus::class => CommandBusFactory::class, EventStore::class => EventStoreFactory::class, Connection::class => ConnectionFactory::class, - - // @todo move db info to a class to get ENV vars - 'db_dsn' => function () { - return 'mysql:host=localhost;dbname=conticket'; - }, - 'db_user' => function () { - return 'root'; - }, - 'db_password' => function () { - return null; - }, ], ]; })(); diff --git a/public/index.php b/public/index.php index e7d1703..9e205eb 100644 --- a/public/index.php +++ b/public/index.php @@ -7,6 +7,9 @@ (function () { require __DIR__ . '/../vendor/autoload.php'; + /* loading .env variables */ + (new \Dotenv\Dotenv(__DIR__ . '/..'))->load(); + /* @var $serviceManager \Zend\ServiceManager\ServiceManager */ $serviceManager = require __DIR__ . '/../config/service-manager.php'; diff --git a/src/Conference/Domain/Command/CreateConference.php b/src/Conference/Domain/Command/CreateConference.php index f8f6842..f487fc6 100644 --- a/src/Conference/Domain/Command/CreateConference.php +++ b/src/Conference/Domain/Command/CreateConference.php @@ -79,13 +79,7 @@ public static function fromRequestData( string $author, \DateTimeImmutable $date ): self { - return new self( - $conferenceId, - $name, - $description, - $author, - $date - ); + return new self($conferenceId, $name, $description, $author, $date); } /** diff --git a/src/Conference/Infrastructure/Service/ApplicationFactory.php b/src/Conference/Infrastructure/Service/ApplicationFactory.php index fd8e5c5..04c612d 100644 --- a/src/Conference/Infrastructure/Service/ApplicationFactory.php +++ b/src/Conference/Infrastructure/Service/ApplicationFactory.php @@ -33,4 +33,4 @@ public function __invoke(ContainerInterface $container): Application { return new Application($container->get(FastRouteRouter::class), $container); } -} \ No newline at end of file +} diff --git a/src/Conference/Infrastructure/Service/ConnectionFactory.php b/src/Conference/Infrastructure/Service/ConnectionFactory.php index 5a575a7..b159023 100644 --- a/src/Conference/Infrastructure/Service/ConnectionFactory.php +++ b/src/Conference/Infrastructure/Service/ConnectionFactory.php @@ -35,9 +35,9 @@ public function __invoke(ContainerInterface $container): Connection $connection = new Connection( [ 'pdo' => new PDO( - $container->get('db_dsn'), - $container->get('db_user'), - $container->get('db_password') + getenv('DB_DSN'), + getenv('DB_USER'), + getenv('DB_PASSWORD') ), ], new Driver() diff --git a/src/Conference/Infrastructure/Service/RouterFactory.php b/src/Conference/Infrastructure/Service/RouterFactory.php deleted file mode 100644 index a6634ca..0000000 --- a/src/Conference/Infrastructure/Service/RouterFactory.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ -final class RouterFactory -{ - public function __invoke(ContainerInterface $container): FastRouteRouter - { - return new FastRouteRouter(); - } -} \ No newline at end of file From 3da502818a754edd6d6d46fffa920c42d4c9414b Mon Sep 17 00:00:00 2001 From: lucianoqueiroz Date: Sun, 5 Mar 2017 09:40:07 -0300 Subject: [PATCH 06/11] adding docheader --- config/commands.php | 16 ++++++++++++++++ config/repositories.php | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/config/commands.php b/config/commands.php index 5db7842..03fdd90 100644 --- a/config/commands.php +++ b/config/commands.php @@ -1,4 +1,20 @@ Date: Sun, 5 Mar 2017 09:50:58 -0300 Subject: [PATCH 07/11] adding eof --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 4985192..e69f3ac 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,3 @@ DB_DSN=mysql:host=localhost;dbname=conticket DB_USER=root -DB_PASSWORD= \ No newline at end of file +DB_PASSWORD= From 63d110a4a1048078cd977cf2804212dc36f5acb6 Mon Sep 17 00:00:00 2001 From: lucianoqueiroz Date: Mon, 6 Mar 2017 18:35:47 -0300 Subject: [PATCH 08/11] fixing middlewares config file --- config/middlewares.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/config/middlewares.php b/config/middlewares.php index 958c34d..69ae790 100644 --- a/config/middlewares.php +++ b/config/middlewares.php @@ -5,8 +5,10 @@ use Conticket\Conference\Infrastructure\Middleware\CreateConferenceMiddleware; use Conticket\Conference\Factory\Middleware\CreateConferenceMiddlewareFactory; -return [ - 'factories' => [ - CreateConferenceMiddleware::class => CreateConferenceMiddlewareFactory::class, - ], -]; +return (function () { + return [ + 'factories' => [ + CreateConferenceMiddleware::class => CreateConferenceMiddlewareFactory::class, + ], + ]; +})(); \ No newline at end of file From a4ffc9df3d53ab406517d7ffab4fd6d03cb90668 Mon Sep 17 00:00:00 2001 From: lucianoqueiroz Date: Tue, 7 Mar 2017 22:10:41 -0300 Subject: [PATCH 09/11] adding pdo factory --- config/middlewares.php | 2 +- config/service-manager.php | 4 +-- config/services.php | 15 ++++----- public/index.php | 1 - .../Service/ConnectionFactory.php | 12 +++---- .../Infrastructure/Service/PDOFactory.php | 31 +++++++++++++++++++ 6 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 src/Conference/Infrastructure/Service/PDOFactory.php diff --git a/config/middlewares.php b/config/middlewares.php index 69ae790..a1a49a6 100644 --- a/config/middlewares.php +++ b/config/middlewares.php @@ -11,4 +11,4 @@ CreateConferenceMiddleware::class => CreateConferenceMiddlewareFactory::class, ], ]; -})(); \ No newline at end of file +})(); diff --git a/config/service-manager.php b/config/service-manager.php index 308e6f4..39ff25f 100644 --- a/config/service-manager.php +++ b/config/service-manager.php @@ -7,10 +7,10 @@ return (function () { return new \Zend\ServiceManager\ServiceManager( array_merge_recursive( + require __DIR__ . '/services.php', require __DIR__ . '/commands.php', require __DIR__ . '/middlewares.php', - require __DIR__ . '/repositories.php', - require __DIR__ . '/services.php' + require __DIR__ . '/repositories.php' ) ); })(); diff --git a/config/services.php b/config/services.php index 7fc3e89..d256f4e 100644 --- a/config/services.php +++ b/config/services.php @@ -2,11 +2,11 @@ declare(strict_types=1); +use Conticket\Conference\Infrastructure\Service\ApplicationFactory; use Conticket\Conference\Infrastructure\Service\CommandBusFactory; use Conticket\Conference\Infrastructure\Service\ConnectionFactory; use Conticket\Conference\Infrastructure\Service\EventStoreFactory; -use Conticket\Conference\Infrastructure\Service\ApplicationFactory; -use Conticket\Conference\Infrastructure\Service\RouterFactory; +use Conticket\Conference\Infrastructure\Service\PDOFactory; use Doctrine\DBAL\Connection; use Prooph\EventStore\EventStore; use Prooph\ServiceBus\CommandBus; @@ -17,11 +17,12 @@ return (function () { return [ 'factories' => [ - Application::class => ApplicationFactory::class, - FastRouteRouter::class => InvokableFactory::class, - CommandBus::class => CommandBusFactory::class, - EventStore::class => EventStoreFactory::class, - Connection::class => ConnectionFactory::class, + Application::class => ApplicationFactory::class, + FastRouteRouter::class => InvokableFactory::class, + CommandBus::class => CommandBusFactory::class, + EventStore::class => EventStoreFactory::class, + Connection::class => ConnectionFactory::class, + \PDO::class => PDOFactory::class, ], ]; })(); diff --git a/public/index.php b/public/index.php index 9e205eb..b1a99d2 100644 --- a/public/index.php +++ b/public/index.php @@ -7,7 +7,6 @@ (function () { require __DIR__ . '/../vendor/autoload.php'; - /* loading .env variables */ (new \Dotenv\Dotenv(__DIR__ . '/..'))->load(); /* @var $serviceManager \Zend\ServiceManager\ServiceManager */ diff --git a/src/Conference/Infrastructure/Service/ConnectionFactory.php b/src/Conference/Infrastructure/Service/ConnectionFactory.php index b159023..81858b0 100644 --- a/src/Conference/Infrastructure/Service/ConnectionFactory.php +++ b/src/Conference/Infrastructure/Service/ConnectionFactory.php @@ -21,24 +21,19 @@ namespace Conticket\Conference\Infrastructure\Service; use Doctrine\DBAL\Connection; + use Doctrine\DBAL\Driver\PDOMySql\Driver; use Doctrine\DBAL\Schema\SchemaException; use Interop\Container\ContainerInterface; -use PDO; use Prooph\EventStore\Adapter\Doctrine\Schema\EventStoreSchema; final class ConnectionFactory { public function __invoke(ContainerInterface $container): Connection { - // @todo create service for \PDO - $connection = new Connection( + $connection = new Connection( [ - 'pdo' => new PDO( - getenv('DB_DSN'), - getenv('DB_USER'), - getenv('DB_PASSWORD') - ), + 'pdo' => $container->get(\PDO::class) ], new Driver() ); @@ -51,6 +46,7 @@ public function __invoke(ContainerInterface $container): Connection foreach ($schema->toSql($connection->getDatabasePlatform()) as $sql) { $connection->exec($sql); } + } catch (SchemaException $ignored) { // this is ignored for now - we don't want to re-create the schema every time } diff --git a/src/Conference/Infrastructure/Service/PDOFactory.php b/src/Conference/Infrastructure/Service/PDOFactory.php new file mode 100644 index 0000000..735919d --- /dev/null +++ b/src/Conference/Infrastructure/Service/PDOFactory.php @@ -0,0 +1,31 @@ + Date: Tue, 7 Mar 2017 22:14:59 -0300 Subject: [PATCH 10/11] sorting packages --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index dd8d69e..14017ac 100644 --- a/composer.json +++ b/composer.json @@ -33,10 +33,10 @@ "prooph/event-store-doctrine-adapter": "^3.3", "prooph/service-bus": "^5.2", "ramsey/uuid": "^2.8", + "vlucas/phpdotenv": "^2.4", "zendframework/zend-expressive": "^1.0", "zendframework/zend-expressive-fastroute": "^1.0", - "zendframework/zend-servicemanager": "^3.2", - "vlucas/phpdotenv": "^2.4" + "zendframework/zend-servicemanager": "^3.2" }, "require-dev": { "behat/behat": "3.*@stable", From 5e382fe1fb726bd7c0d66afa88ae912165323b22 Mon Sep 17 00:00:00 2001 From: lucianoqueiroz Date: Wed, 8 Mar 2017 11:42:08 -0300 Subject: [PATCH 11/11] implementing factory interface in all service factories --- .../Infrastructure/Service/ApplicationFactory.php | 5 +++-- src/Conference/Infrastructure/Service/CommandBusFactory.php | 5 +++-- src/Conference/Infrastructure/Service/ConnectionFactory.php | 6 +++--- src/Conference/Infrastructure/Service/EventStoreFactory.php | 5 +++-- src/Conference/Infrastructure/Service/PDOFactory.php | 5 +++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Conference/Infrastructure/Service/ApplicationFactory.php b/src/Conference/Infrastructure/Service/ApplicationFactory.php index 04c612d..0191b72 100644 --- a/src/Conference/Infrastructure/Service/ApplicationFactory.php +++ b/src/Conference/Infrastructure/Service/ApplicationFactory.php @@ -23,13 +23,14 @@ use Interop\Container\ContainerInterface; use Zend\Expressive\Router\FastRouteRouter; use Zend\Expressive\Application; +use Zend\ServiceManager\Factory\FactoryInterface; /** * @author Luciano Queiroz */ -final class ApplicationFactory +final class ApplicationFactory implements FactoryInterface { - public function __invoke(ContainerInterface $container): Application + public function __invoke(ContainerInterface $container, $requestedName, array $options = null): Application { return new Application($container->get(FastRouteRouter::class), $container); } diff --git a/src/Conference/Infrastructure/Service/CommandBusFactory.php b/src/Conference/Infrastructure/Service/CommandBusFactory.php index f448ac5..5e4c090 100644 --- a/src/Conference/Infrastructure/Service/CommandBusFactory.php +++ b/src/Conference/Infrastructure/Service/CommandBusFactory.php @@ -27,13 +27,14 @@ use Prooph\ServiceBus\CommandBus; use Prooph\ServiceBus\MessageBus; use Prooph\ServiceBus\Plugin\ServiceLocatorPlugin; +use Zend\ServiceManager\Factory\FactoryInterface; /** * @author Jefersson Nathan */ -final class CommandBusFactory +final class CommandBusFactory implements FactoryInterface { - public function __invoke(ContainerInterface $container): CommandBus + public function __invoke(ContainerInterface $container, $requestedName, array $options = null): CommandBus { $commandBus = new CommandBus(); $commandBus->utilize(new ServiceLocatorPlugin($container)); diff --git a/src/Conference/Infrastructure/Service/ConnectionFactory.php b/src/Conference/Infrastructure/Service/ConnectionFactory.php index 81858b0..de99e4a 100644 --- a/src/Conference/Infrastructure/Service/ConnectionFactory.php +++ b/src/Conference/Infrastructure/Service/ConnectionFactory.php @@ -21,15 +21,15 @@ namespace Conticket\Conference\Infrastructure\Service; use Doctrine\DBAL\Connection; - use Doctrine\DBAL\Driver\PDOMySql\Driver; use Doctrine\DBAL\Schema\SchemaException; use Interop\Container\ContainerInterface; use Prooph\EventStore\Adapter\Doctrine\Schema\EventStoreSchema; +use Zend\ServiceManager\Factory\FactoryInterface; -final class ConnectionFactory +final class ConnectionFactory implements FactoryInterface { - public function __invoke(ContainerInterface $container): Connection + public function __invoke(ContainerInterface $container, $requestedName, array $options = null): Connection { $connection = new Connection( [ diff --git a/src/Conference/Infrastructure/Service/EventStoreFactory.php b/src/Conference/Infrastructure/Service/EventStoreFactory.php index c0cb3cb..a6c3f26 100644 --- a/src/Conference/Infrastructure/Service/EventStoreFactory.php +++ b/src/Conference/Infrastructure/Service/EventStoreFactory.php @@ -28,13 +28,14 @@ use Prooph\EventStore\Adapter\Doctrine\DoctrineEventStoreAdapter; use Prooph\EventStore\Adapter\PayloadSerializer\JsonPayloadSerializer; use Prooph\EventStore\EventStore; +use Zend\ServiceManager\Factory\FactoryInterface; /** * @author Jefersson Nathan */ -final class EventStoreFactory +final class EventStoreFactory implements FactoryInterface { - public function __invoke(ContainerInterface $container): EventStore + public function __invoke(ContainerInterface $container, $requestedName, array $options = null): EventStore { return new EventStore( new DoctrineEventStoreAdapter( diff --git a/src/Conference/Infrastructure/Service/PDOFactory.php b/src/Conference/Infrastructure/Service/PDOFactory.php index 735919d..526f9dd 100644 --- a/src/Conference/Infrastructure/Service/PDOFactory.php +++ b/src/Conference/Infrastructure/Service/PDOFactory.php @@ -21,10 +21,11 @@ namespace Conticket\Conference\Infrastructure\Service; use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; -final class PDOFactory +final class PDOFactory implements FactoryInterface { - public function __invoke(ContainerInterface $container): \PDO + public function __invoke(ContainerInterface $container, $requestedName, array $options = null): \PDO { return new \PDO(getenv('DB_DSN'), getenv('DB_USER'), getenv('DB_PASSWORD')); }