@@ 16-44 (lines=29) @@ | ||
13 | * |
|
14 | * @package T4web\DomainModule |
|
15 | */ |
|
16 | class EntityFactoryAbstractFactory implements AbstractFactoryInterface |
|
17 | { |
|
18 | public function canCreate(ContainerInterface $container, $requestedName) |
|
19 | { |
|
20 | return substr($requestedName, -strlen('EntityFactory')) == 'EntityFactory'; |
|
21 | } |
|
22 | ||
23 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
24 | { |
|
25 | $namespace = strstr($requestedName, 'EntityFactory', true); |
|
26 | ||
27 | $namespaceParts = explode('\\', trim($namespace, "\\")); |
|
28 | ||
29 | $collectionClass = 'ArrayObject'; |
|
30 | if (count($namespaceParts) > 1) { |
|
31 | list($moduleName, $entityName) = $namespaceParts; |
|
32 | $entityClass = "$moduleName\\$entityName\\$entityName"; |
|
33 | } else { |
|
34 | $entityName = $namespaceParts[0]; |
|
35 | ||
36 | /** @var Config $config */ |
|
37 | $config = $container->get("$entityName\\Infrastructure\\Config"); |
|
38 | $entityClass = $config->getEntityClass($entityName); |
|
39 | $collectionClass = $config->getCollectionClass($entityName); |
|
40 | } |
|
41 | ||
42 | return new EntityFactory($entityClass, $collectionClass); |
|
43 | } |
|
44 | } |
|
45 |
@@ 15-40 (lines=26) @@ | ||
12 | * |
|
13 | * @package T4web\DomainModule\Service |
|
14 | */ |
|
15 | class DeleterAbstractFactory implements AbstractFactoryInterface |
|
16 | { |
|
17 | public function canCreate(ContainerInterface $container, $requestedName) |
|
18 | { |
|
19 | return substr($requestedName, -strlen('Service\Deleter')) == 'Service\Deleter'; |
|
20 | } |
|
21 | ||
22 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
23 | { |
|
24 | $namespace = strstr($requestedName, 'Service\Deleter', true); |
|
25 | ||
26 | $namespaceParts = explode('\\', trim($namespace, "\\")); |
|
27 | ||
28 | if (count($namespaceParts) > 1) { |
|
29 | list($moduleName, $entityName) = $namespaceParts; |
|
30 | $repository = $container->get("$moduleName\\$entityName\\Infrastructure\\Repository"); |
|
31 | $entityEventManager = $container->get("$moduleName\\$entityName\\EntityEventManager"); |
|
32 | } else { |
|
33 | $entityName = $namespaceParts[0]; |
|
34 | $repository = $container->get("$entityName\\Infrastructure\\Repository"); |
|
35 | $entityEventManager = $container->get("$entityName\\EntityEventManager"); |
|
36 | } |
|
37 | ||
38 | return new Deleter($repository, $entityEventManager); |
|
39 | } |
|
40 | } |
|
41 |
@@ 15-40 (lines=26) @@ | ||
12 | * |
|
13 | * @package T4web\DomainModule\Service |
|
14 | */ |
|
15 | class UpdaterAbstractFactory implements AbstractFactoryInterface |
|
16 | { |
|
17 | public function canCreate(ContainerInterface $container, $requestedName) |
|
18 | { |
|
19 | return substr($requestedName, -strlen('Service\Updater')) == 'Service\Updater'; |
|
20 | } |
|
21 | ||
22 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
23 | { |
|
24 | $namespace = strstr($requestedName, 'Service\Updater', true); |
|
25 | ||
26 | $namespaceParts = explode('\\', trim($namespace, "\\")); |
|
27 | ||
28 | if (count($namespaceParts) > 1) { |
|
29 | list($moduleName, $entityName) = $namespaceParts; |
|
30 | $repository = $container->get("$moduleName\\$entityName\\Infrastructure\\Repository"); |
|
31 | $entityEventManager = $container->get("$moduleName\\$entityName\\EntityEventManager"); |
|
32 | } else { |
|
33 | $entityName = $namespaceParts[0]; |
|
34 | $repository = $container->get("$entityName\\Infrastructure\\Repository"); |
|
35 | $entityEventManager = $container->get("$entityName\\EntityEventManager"); |
|
36 | } |
|
37 | ||
38 | return new Updater($repository, $entityEventManager); |
|
39 | } |
|
40 | } |
|
41 |