for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace T4web\DomainModule\Infrastructure;
use Zend\ServiceManager\Factory\AbstractFactoryInterface;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use T4webInfrastructure\Config;
/**
* Create Service by template:
* MODULE-NAME\ENTITY-NAME\Infrastructure\Config
*
* @package T4web\DomainModule\Infrastructure
*/
class ConfigAbstractFactory implements AbstractFactoryInterface
{
public function canCreate(ContainerInterface $container, $requestedName)
return substr($requestedName, -strlen('Infrastructure\Config')) == 'Infrastructure\Config';
}
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
$namespace = strstr($requestedName, 'Infrastructure\Config', true);
$namespaceParts = explode('\\', trim($namespace, "\\"));
if (count($namespaceParts) > 1) {
$entityName = $namespaceParts[1];
} else {
$entityName = $namespaceParts[0];
$config = $container->get('Config');
if (!isset($config['entity_map'])) {
throw new ServiceNotCreatedException("You must define
and configure $entityName in 'entity_map' config entry");
return new Config($config['entity_map']);