[DoctrineBundle] simplified code
This commit is contained in:
parent
0f5f28c039
commit
71330e91d0
@ -42,44 +42,42 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
*/
|
*/
|
||||||
protected function loadMappingInformation(array $objectManager, ContainerBuilder $container)
|
protected function loadMappingInformation(array $objectManager, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
if (isset($objectManager['mappings'])) {
|
foreach ($objectManager['mappings'] as $mappingName => $mappingConfig) {
|
||||||
foreach ($objectManager['mappings'] as $mappingName => $mappingConfig) {
|
$mappingConfig = array_replace(array(
|
||||||
$mappingConfig = array_replace(array(
|
'dir' => false,
|
||||||
'dir' => false,
|
'type' => false,
|
||||||
'type' => false,
|
'prefix' => false,
|
||||||
'prefix' => false,
|
), (array) $mappingConfig);
|
||||||
), $mappingConfig);
|
|
||||||
|
|
||||||
$mappingConfig['dir'] = $container->getParameterBag()->resolveValue($mappingConfig['dir']);
|
$mappingConfig['dir'] = $container->getParameterBag()->resolveValue($mappingConfig['dir']);
|
||||||
// a bundle configuration is detected by realizing that the specified dir is not absolute and existing
|
// a bundle configuration is detected by realizing that the specified dir is not absolute and existing
|
||||||
if (!isset($mappingConfig['is_bundle'])) {
|
if (!isset($mappingConfig['is_bundle'])) {
|
||||||
$mappingConfig['is_bundle'] = !file_exists($mappingConfig['dir']);
|
$mappingConfig['is_bundle'] = !file_exists($mappingConfig['dir']);
|
||||||
}
|
|
||||||
|
|
||||||
if ($mappingConfig['is_bundle']) {
|
|
||||||
$bundle = null;
|
|
||||||
foreach ($container->getParameter('kernel.bundles') as $name => $class) {
|
|
||||||
if ($mappingName === $name) {
|
|
||||||
$bundle = new \ReflectionClass($class);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === $bundle) {
|
|
||||||
throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled.', $mappingName));
|
|
||||||
}
|
|
||||||
|
|
||||||
$mappingConfig = $this->getMappingDriverBundleConfigDefaults($mappingConfig, $bundle, $container);
|
|
||||||
if (!$mappingConfig) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertValidMappingConfiguration($mappingConfig, $objectManager['name']);
|
|
||||||
$this->setMappingDriverConfig($mappingConfig, $mappingName);
|
|
||||||
$this->setMappingDriverAlias($mappingConfig, $mappingName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($mappingConfig['is_bundle']) {
|
||||||
|
$bundle = null;
|
||||||
|
foreach ($container->getParameter('kernel.bundles') as $name => $class) {
|
||||||
|
if ($mappingName === $name) {
|
||||||
|
$bundle = new \ReflectionClass($class);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $bundle) {
|
||||||
|
throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled.', $mappingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
$mappingConfig = $this->getMappingDriverBundleConfigDefaults($mappingConfig, $bundle, $container);
|
||||||
|
if (!$mappingConfig) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertValidMappingConfiguration($mappingConfig, $objectManager['name']);
|
||||||
|
$this->setMappingDriverConfig($mappingConfig, $mappingName);
|
||||||
|
$this->setMappingDriverAlias($mappingConfig, $mappingName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user