[DoctrineBridge] Allow bundles to define a driver type "attribute"
This commit is contained in:
parent
3f42c08abd
commit
cecaa7815a
@ -151,7 +151,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$bundleConfig['dir']) {
|
if (!$bundleConfig['dir']) {
|
||||||
if (\in_array($bundleConfig['type'], ['annotation', 'staticphp'])) {
|
if (\in_array($bundleConfig['type'], ['annotation', 'staticphp', 'attribute'])) {
|
||||||
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingObjectDefaultName();
|
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingObjectDefaultName();
|
||||||
} else {
|
} else {
|
||||||
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory();
|
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory();
|
||||||
@ -193,6 +193,10 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
$args[0] = array_merge(array_values($driverPaths), $args[0]);
|
$args[0] = array_merge(array_values($driverPaths), $args[0]);
|
||||||
}
|
}
|
||||||
$mappingDriverDef->setArguments($args);
|
$mappingDriverDef->setArguments($args);
|
||||||
|
} elseif ('attribute' === $driverType) {
|
||||||
|
$mappingDriverDef = new Definition($this->getMetadataDriverClass($driverType), [
|
||||||
|
array_values($driverPaths),
|
||||||
|
]);
|
||||||
} elseif ('annotation' == $driverType) {
|
} elseif ('annotation' == $driverType) {
|
||||||
$mappingDriverDef = new Definition($this->getMetadataDriverClass($driverType), [
|
$mappingDriverDef = new Definition($this->getMetadataDriverClass($driverType), [
|
||||||
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
|
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
|
||||||
@ -236,8 +240,8 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
|
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\in_array($mappingConfig['type'], ['xml', 'yml', 'annotation', 'php', 'staticphp'])) {
|
if (!\in_array($mappingConfig['type'], ['xml', 'yml', 'annotation', 'php', 'staticphp', 'attribute'])) {
|
||||||
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 new driver to the "%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver')));
|
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php", "staticphp" or "attribute" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. You can register them by adding a new driver to the "%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +441,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
{
|
{
|
||||||
@trigger_error(sprintf('Not declaring the "%s" method in class "%s" is deprecated since Symfony 4.4. This method will be abstract in Symfony 5.0.', __METHOD__, static::class), \E_USER_DEPRECATED);
|
@trigger_error(sprintf('Not declaring the "%s" method in class "%s" is deprecated since Symfony 4.4. This method will be abstract in Symfony 5.0.', __METHOD__, static::class), \E_USER_DEPRECATED);
|
||||||
|
|
||||||
return '%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%');
|
return '%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class').'%';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user