[DoctrineBundle] fixed CS
This commit is contained in:
parent
aab56fa91e
commit
631393e29d
|
@ -123,8 +123,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||
}
|
||||
$this->drivers[$mappingConfig['type']][$mappingConfig['prefix']] = realpath($mappingConfig['dir']);
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Invalid mapping path given. ".
|
||||
"Cannot load mapping/bundle named '" . $mappingName . "'.");
|
||||
throw new \InvalidArgumentException(sprintf('Invalid mapping path given. Cannot load mapping/bundle named "%s".', $mappingName));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,15 +176,15 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||
protected function registerMappingDrivers($objectManager, ContainerBuilder $container)
|
||||
{
|
||||
// configure metadata driver for each bundle based on the type of mapping files found
|
||||
if ($container->hasDefinition($this->getObjectManagerElementName($objectManager['name'] . '_metadata_driver'))) {
|
||||
$chainDriverDef = $container->getDefinition($this->getObjectManagerElementName($objectManager['name'] . '_metadata_driver'));
|
||||
if ($container->hasDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'))) {
|
||||
$chainDriverDef = $container->getDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'));
|
||||
} else {
|
||||
$chainDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.driver_chain.class%'));
|
||||
$chainDriverDef->setPublic(false);
|
||||
}
|
||||
|
||||
foreach ($this->drivers as $driverType => $driverPaths) {
|
||||
$mappingService = $this->getObjectManagerElementName($objectManager['name'] . '_'.$driverType.'_metadata_driver');
|
||||
$mappingService = $this->getObjectManagerElementName($objectManager['name'].'_'.$driverType.'_metadata_driver');
|
||||
if ($container->hasDefinition($mappingService)) {
|
||||
$mappingDriverDef = $container->getDefinition($mappingService);
|
||||
$args = $mappingDriverDef->getArguments();
|
||||
|
@ -196,12 +195,12 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||
}
|
||||
$mappingDriverDef->setArguments($args);
|
||||
} else if ($driverType == 'annotation') {
|
||||
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.' . $driverType . '.class%'), array(
|
||||
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array(
|
||||
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
|
||||
array_values($driverPaths)
|
||||
));
|
||||
} else {
|
||||
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.' . $driverType . '.class%'), array(
|
||||
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array(
|
||||
array_values($driverPaths)
|
||||
));
|
||||
}
|
||||
|
@ -214,7 +213,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
$container->setDefinition($this->getObjectManagerElementName($objectManager['name'] . '_metadata_driver'), $chainDriverDef);
|
||||
$container->setDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'), $chainDriverDef);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,20 +225,19 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||
protected function assertValidMappingConfiguration(array $mappingConfig, $objectManagerName)
|
||||
{
|
||||
if (!$mappingConfig['type'] || !$mappingConfig['dir'] || !$mappingConfig['prefix']) {
|
||||
throw new \InvalidArgumentException("Mapping definitions for manager '".$objectManagerName."' ".
|
||||
"require at least the 'type', 'dir' and 'prefix' options.");
|
||||
throw new \InvalidArgumentException(sprintf('Mapping definitions for manager "%s" require at least the "type", "dir" and "prefix" options.', $objectManagerName));
|
||||
}
|
||||
|
||||
if (!file_exists($mappingConfig['dir'])) {
|
||||
throw new \InvalidArgumentException("Specified non-existing directory '" . $mappingConfig['dir'] . "' as mapping source.");
|
||||
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as mapping source.', $mappingConfig['dir']));
|
||||
}
|
||||
|
||||
if (!in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
|
||||
throw new \InvalidArgumentException("Can only configure 'xml', 'yml', 'annotation', 'php' or ".
|
||||
"'staticphp' through the DoctrineBundle. Use your own bundle to configure other metadata drivers. " .
|
||||
"You can register them by adding a a new driver to the ".
|
||||
"'" . $this->getObjectManagerElementName($objectManagerName . ".metadata_driver")."' service definition."
|
||||
);
|
||||
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
|
||||
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
|
||||
'You can register them by adding a a new driver to the '.
|
||||
'"%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'.metadata_driver')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,4 +302,4 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||
* @return string
|
||||
*/
|
||||
abstract protected function getMappingResourceConfigDirectory();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
|||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('dbal.xml');
|
||||
|
||||
if (empty ($config['default_connection'])) {
|
||||
if (empty($config['default_connection'])) {
|
||||
$keys = array_keys($config['connections']);
|
||||
$config['default_connection'] = reset($keys);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
|||
|
||||
$container->setParameter('doctrine.orm.entity_managers', $entityManagers = array_keys($config['entity_managers']));
|
||||
|
||||
if (empty ($config['default_entity_manager'])) {
|
||||
if (empty($config['default_entity_manager'])) {
|
||||
$config['default_entity_manager'] = reset($entityManagers);
|
||||
}
|
||||
|
||||
|
@ -174,33 +174,33 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
|||
$this->loadOrmEntityManagerMappingInformation($entityManager, $ormConfigDef, $container);
|
||||
$this->loadOrmCacheDrivers($entityManager, $container);
|
||||
|
||||
$uniqueMethods = array(
|
||||
'setMetadataCacheImpl' => new Reference(sprintf('doctrine.orm.%s_metadata_cache', $entityManager['name'])),
|
||||
'setQueryCacheImpl' => new Reference(sprintf('doctrine.orm.%s_query_cache', $entityManager['name'])),
|
||||
'setResultCacheImpl' => new Reference(sprintf('doctrine.orm.%s_result_cache', $entityManager['name'])),
|
||||
'setMetadataDriverImpl' => new Reference('doctrine.orm.'.$entityManager['name'].'_metadata_driver'),
|
||||
'setProxyDir' => '%doctrine.orm.proxy_dir%',
|
||||
'setProxyNamespace' => '%doctrine.orm.proxy_namespace%',
|
||||
'setAutoGenerateProxyClasses' => '%doctrine.orm.auto_generate_proxy_classes%',
|
||||
'setClassMetadataFactoryName' => $entityManager['class_metadata_factory_name'],
|
||||
$methods = array(
|
||||
'setMetadataCacheImpl' => new Reference(sprintf('doctrine.orm.%s_metadata_cache', $entityManager['name'])),
|
||||
'setQueryCacheImpl' => new Reference(sprintf('doctrine.orm.%s_query_cache', $entityManager['name'])),
|
||||
'setResultCacheImpl' => new Reference(sprintf('doctrine.orm.%s_result_cache', $entityManager['name'])),
|
||||
'setMetadataDriverImpl' => new Reference('doctrine.orm.'.$entityManager['name'].'_metadata_driver'),
|
||||
'setProxyDir' => '%doctrine.orm.proxy_dir%',
|
||||
'setProxyNamespace' => '%doctrine.orm.proxy_namespace%',
|
||||
'setAutoGenerateProxyClasses' => '%doctrine.orm.auto_generate_proxy_classes%',
|
||||
'setClassMetadataFactoryName' => $entityManager['class_metadata_factory_name'],
|
||||
);
|
||||
foreach ($uniqueMethods as $method => $arg) {
|
||||
foreach ($methods as $method => $arg) {
|
||||
$ormConfigDef->addMethodCall($method, array($arg));
|
||||
}
|
||||
|
||||
foreach ($entityManager['hydrators'] as $name => $class) {
|
||||
$ormConfigDef->addMethodCall('addCustomHydrationMode', array ($name, $class));
|
||||
$ormConfigDef->addMethodCall('addCustomHydrationMode', array($name, $class));
|
||||
}
|
||||
|
||||
if (!empty($entityManager['dql'])) {
|
||||
foreach ($entityManager['dql']['string_functions'] as $name => $function) {
|
||||
$ormConfigDef->addMethodCall('addCustomStringFunction', array ($name, $function));
|
||||
$ormConfigDef->addMethodCall('addCustomStringFunction', array($name, $function));
|
||||
}
|
||||
foreach ($entityManager['dql']['numeric_functions'] as $name => $function) {
|
||||
$ormConfigDef->addMethodCall('addCustomNumericFunction', array ($name, $function));
|
||||
$ormConfigDef->addMethodCall('addCustomNumericFunction', array($name, $function));
|
||||
}
|
||||
foreach ($entityManager['dql']['datetime_functions'] as $name => $function) {
|
||||
$ormConfigDef->addMethodCall('addCustomDatetimeFunction', array ($name, $function));
|
||||
$ormConfigDef->addMethodCall('addCustomDatetimeFunction', array($name, $function));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
|||
|
||||
protected function getObjectManagerElementName($name)
|
||||
{
|
||||
return 'doctrine.orm.' . $name;
|
||||
return 'doctrine.orm.'.$name;
|
||||
}
|
||||
|
||||
protected function getMappingObjectDefaultName()
|
||||
|
@ -324,10 +324,10 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
|||
{
|
||||
switch ($cacheDriver['type']) {
|
||||
case 'memcache':
|
||||
$memcacheClass = !empty ($cacheDriver['class']) ? $cacheDriver['class'] : '%doctrine.orm.cache.memcache.class%';
|
||||
$memcacheInstanceClass = !empty ($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%doctrine.orm.cache.memcache_instance.class%';
|
||||
$memcacheHost = !empty ($cacheDriver['host']) ? $cacheDriver['host'] : '%doctrine.orm.cache.memcache_host%';
|
||||
$memcachePort = !empty ($cacheDriver['port']) ? $cacheDriver['port'] : '%doctrine.orm.cache.memcache_port%';
|
||||
$memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%doctrine.orm.cache.memcache.class%';
|
||||
$memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%doctrine.orm.cache.memcache_instance.class%';
|
||||
$memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%doctrine.orm.cache.memcache_host%';
|
||||
$memcachePort = !empty($cacheDriver['port']) ? $cacheDriver['port'] : '%doctrine.orm.cache.memcache_port%';
|
||||
$cacheDef = new Definition($memcacheClass);
|
||||
$memcacheInstance = new Definition($memcacheInstanceClass);
|
||||
$memcacheInstance->addMethodCall('connect', array(
|
||||
|
|
Reference in New Issue