| @@ 15-30 (lines=16) @@ | ||
| 12 | * |
|
| 13 | * @package T4web\DomainModule |
|
| 14 | */ |
|
| 15 | class EntityFactoryAbstractFactory implements AbstractFactoryInterface |
|
| 16 | { |
|
| 17 | public function canCreateServiceWithName(ServiceLocatorInterface $serviceManager, $name, $requestedName) |
|
| 18 | { |
|
| 19 | return substr($requestedName, -strlen('EntityFactory')) == 'EntityFactory'; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function createServiceWithName(ServiceLocatorInterface $serviceManager, $name, $requestedName) |
|
| 23 | { |
|
| 24 | $namespace = strstr($requestedName, 'EntityFactory', true); |
|
| 25 | ||
| 26 | list($moduleName, $entityName) = explode('\\', $namespace); |
|
| 27 | ||
| 28 | return new EntityFactory("$moduleName\\$entityName\\$entityName"); |
|
| 29 | } |
|
| 30 | } |
|
| @@ 15-32 (lines=18) @@ | ||
| 12 | * |
|
| 13 | * @package T4web\DomainModule\Infrastructure |
|
| 14 | */ |
|
| 15 | class CriteriaFactoryAbstractFactory implements AbstractFactoryInterface |
|
| 16 | { |
|
| 17 | public function canCreateServiceWithName(ServiceLocatorInterface $serviceManager, $name, $requestedName) |
|
| 18 | { |
|
| 19 | return substr($requestedName, -strlen('Infrastructure\CriteriaFactory')) == 'Infrastructure\CriteriaFactory'; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function createServiceWithName(ServiceLocatorInterface $serviceManager, $name, $requestedName) |
|
| 23 | { |
|
| 24 | $namespace = strstr($requestedName, 'Infrastructure\CriteriaFactory', true); |
|
| 25 | ||
| 26 | list($moduleName, $entityName) = explode('\\', $namespace); |
|
| 27 | ||
| 28 | return new CriteriaFactory( |
|
| 29 | $serviceManager->get("$moduleName\\$entityName\\Infrastructure\\Config") |
|
| 30 | ); |
|
| 31 | } |
|
| 32 | } |
|