[2.0] Fixing ClassMetadataExporterTask to use existing configured annotation driver for given path instead of re-creating it
This commit is contained in:
parent
c8ef304bcc
commit
61a4a35694
@ -215,13 +215,13 @@ class ConvertMappingTask extends AbstractTask
|
|||||||
|
|
||||||
// Check if it has a class definition in it for annotations
|
// Check if it has a class definition in it for annotations
|
||||||
if (preg_match("/class (.*)/", $contents)) {
|
if (preg_match("/class (.*)/", $contents)) {
|
||||||
return 'annotation';
|
return 'annotation';
|
||||||
// Otherwise lets determine the type based on the extension of the
|
// Otherwise lets determine the type based on the extension of the
|
||||||
// first file in the directory (yml, xml, etc)
|
// first file in the directory (yml, xml, etc)
|
||||||
} else {
|
} else {
|
||||||
$info = pathinfo($files[0]);
|
$info = pathinfo($files[0]);
|
||||||
|
|
||||||
return $info['extension'];
|
return $info['extension'];
|
||||||
}
|
}
|
||||||
// Nothing special for database
|
// Nothing special for database
|
||||||
} else if ($source == 'database') {
|
} else if ($source == 'database') {
|
||||||
@ -237,6 +237,21 @@ class ConvertMappingTask extends AbstractTask
|
|||||||
$em = $this->getConfiguration()->getAttribute('em');
|
$em = $this->getConfiguration()->getAttribute('em');
|
||||||
|
|
||||||
return $em->getConnection()->getSchemaManager();
|
return $em->getConnection()->getSchemaManager();
|
||||||
|
} else if ($type == 'annotation') {
|
||||||
|
$em = $this->getConfiguration()->getAttribute('em');
|
||||||
|
$metadataDriverImpl = $em->getConfiguration()->getMetadataDriverImpl();
|
||||||
|
if ($metadataDriverImpl instanceof \Doctrine\ORM\Mapping\Driver\DriverChain) {
|
||||||
|
foreach ($metadataDriverImpl->getDrivers() as $namespace => $driver) {
|
||||||
|
if ($driver instanceof \Doctrine\ORM\Mapping\Driver\AnnotationDriver) {
|
||||||
|
$paths = $driver->getPaths();
|
||||||
|
if (in_array($source, $paths)) {
|
||||||
|
return $driver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ($metadataDriverImpl instanceof \Doctrine\ORM\Mapping\Driver\AnnotationDriver) {
|
||||||
|
return $metadataDriverImpl;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return $source;
|
return $source;
|
||||||
}
|
}
|
||||||
|
@ -105,10 +105,14 @@ class ClassMetadataExporter
|
|||||||
*/
|
*/
|
||||||
public function getMappingDriver($type, $source = null)
|
public function getMappingDriver($type, $source = null)
|
||||||
{
|
{
|
||||||
|
if ($source instanceof \Doctrine\ORM\Mapping\Driver\Driver) {
|
||||||
|
return $source;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! isset($this->_mappingDrivers[$type])) {
|
if ( ! isset($this->_mappingDrivers[$type])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = $this->_mappingDrivers[$type];
|
$class = $this->_mappingDrivers[$type];
|
||||||
|
|
||||||
if (is_subclass_of($class, 'Doctrine\ORM\Mapping\Driver\AbstractFileDriver')) {
|
if (is_subclass_of($class, 'Doctrine\ORM\Mapping\Driver\AbstractFileDriver')) {
|
||||||
|
Loading…
Reference in New Issue
Block a user