Example #1
0
<?php

use Novuso\Common\Application\Container\ServiceContainer;
$container = new ServiceContainer();
$container->service('event.dispatcher', function ($container) {
    return new Novuso\Common\Application\Messaging\Event\EventServiceDispatcher($container);
});
$container->service('test.subscriber', function () {
    return new Novuso\Test\Common\Doubles\Application\Messaging\Event\TestSubscriber();
});
return $container;
Example #2
0
<?php

use Novuso\Common\Application\Container\ServiceContainer;
$container = new ServiceContainer();
$container->service('logger', function () {
    return new Novuso\Test\Common\Doubles\Application\Logging\InMemoryLogger();
});
$container->service('command.pipeline', function ($container) {
    return new Novuso\Common\Application\Messaging\Command\CommandPipeline($container->get('command.handler_resolver'), $container->getParameter('command.filters', []));
});
$container->service('command.bus', function ($container) {
    return new Novuso\Common\Application\Messaging\Command\CommandHandlerBus($container->get('command.handler_resolver'));
});
$container->service('command.handler_resolver', function ($container) {
    return new Novuso\Common\Application\Messaging\Command\Resolver\CommandServiceResolver($container->get('command.service_map'));
});
$container->service('command.service_map', function ($container) {
    $serviceMap = new Novuso\Common\Application\Messaging\Command\Resolver\CommandServiceMap($container);
    $handlers = [];
    $command = 'Novuso\\Test\\Common\\Doubles\\Application\\Messaging\\Command\\CreateTaskCommand';
    $serviceId = 'command.handler.create_task';
    $handlers[$command] = $serviceId;
    $serviceMap->registerHandlers($handlers);
    return $serviceMap;
});
$container->service('command.filter.logger', function ($container) {
    return new Novuso\Common\Application\Messaging\Command\Filter\CommandLogger($container->get('logger'));
});
$container->service('command.handler.create_task', function ($container) {
    return new Novuso\Test\Common\Doubles\Application\Messaging\Command\CreateTaskHandler($container->get('event.dispatcher'));
});
Example #3
0
<?php

use Novuso\Common\Application\Container\ServiceContainer;
use Novuso\Test\Common\Doubles\Domain\Model\Task;
use Novuso\Test\Common\Doubles\Domain\Model\TaskId;
$container = new ServiceContainer();
$container->service('logger', function () {
    return new Novuso\Test\Common\Doubles\Application\Logging\InMemoryLogger();
});
$container->service('query.pipeline', function ($container) {
    return new Novuso\Common\Application\Messaging\Query\QueryPipeline($container->get('query.handler_resolver'), $container->getParameter('query.filters', []));
});
$container->service('query.service', function ($container) {
    return new Novuso\Common\Application\Messaging\Query\QueryHandlerService($container->get('query.handler_resolver'));
});
$container->service('query.handler_resolver', function ($container) {
    return new Novuso\Common\Application\Messaging\Query\Resolver\QueryServiceResolver($container->get('query.service_map'));
});
$container->service('query.service_map', function ($container) {
    $serviceMap = new Novuso\Common\Application\Messaging\Query\Resolver\QueryServiceMap($container);
    $handlers = [];
    $query = 'Novuso\\Test\\Common\\Doubles\\Application\\Messaging\\Query\\GetTaskQuery';
    $serviceId = 'query.handler.get_task';
    $handlers[$query] = $serviceId;
    $serviceMap->registerHandlers($handlers);
    return $serviceMap;
});
$container->service('query.filter.logger', function ($container) {
    return new Novuso\Common\Application\Messaging\Query\Filter\QueryLogger($container->get('logger'));
});
$container->service('query.handler.get_task', function ($container) {