Commit e4e1291b authored by jwage's avatar jwage

[2.0] Bug fix for convert mapping to yaml and annotation directory iterating not being recursive

parent d0bb8ab2
...@@ -90,7 +90,7 @@ class ConvertMappingTask extends AbstractTask ...@@ -90,7 +90,7 @@ class ConvertMappingTask extends AbstractTask
$printer->writeln('You must include a value for all four options: --from, --to and --dest', 'ERROR'); $printer->writeln('You must include a value for all four options: --from, --to and --dest', 'ERROR');
return false; return false;
} }
if ($args['to'] != 'annotation' && $args['extend']) { if ($args['to'] != 'annotation' && isset($args['extend'])) {
$printer->writeln('You can only use the --extend argument when converting to annoations.'); $printer->writeln('You can only use the --extend argument when converting to annoations.');
return false; return false;
} }
...@@ -133,7 +133,12 @@ class ConvertMappingTask extends AbstractTask ...@@ -133,7 +133,12 @@ class ConvertMappingTask extends AbstractTask
{ {
throw new \InvalidArgumentException(sprintf('No schema mapping files found in "%s"', $path)); throw new \InvalidArgumentException(sprintf('No schema mapping files found in "%s"', $path));
} }
$info = pathinfo($files[0]); $contents = file_get_contents($files[0]);
return $info['extension']; if (preg_match("/class (.*)/", $contents)) {
return 'annotation';
} else {
$info = pathinfo($files[0]);
return $info['extension'];
}
} }
} }
\ No newline at end of file
...@@ -142,12 +142,13 @@ class SchemaToolTask extends AbstractTask ...@@ -142,12 +142,13 @@ class SchemaToolTask extends AbstractTask
$classes = array(); $classes = array();
if ($driver instanceof \Doctrine\ORM\Mapping\Driver\AnnotationDriver) { if ($driver instanceof \Doctrine\ORM\Mapping\Driver\AnnotationDriver) {
$iter = new \FilesystemIterator($args['classdir']); $iter = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($args['classdir']),
\RecursiveIteratorIterator::LEAVES_ONLY);
$declared = get_declared_classes(); $declared = get_declared_classes();
foreach ($iter as $item) { foreach ($iter as $item) {
$baseName = $item->getBaseName(); $info = pathinfo($item->getPathName());
if ($baseName[0] == '.') { if (! isset($info['extension']) || $info['extension'] != 'php') {
continue; continue;
} }
require_once $item->getPathName(); require_once $item->getPathName();
......
...@@ -96,9 +96,14 @@ class ClassMetadataExporter ...@@ -96,9 +96,14 @@ class ClassMetadataExporter
foreach ($this->_mappingDirectories as $d) { foreach ($this->_mappingDirectories as $d) {
list($dir, $driver) = $d; list($dir, $driver) = $d;
if ($driver == 'php') { if ($driver == 'php') {
$iter = new \FilesystemIterator($dir); $iter = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir),
\RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($iter as $item) { foreach ($iter as $item) {
$info = pathinfo($item->getPathName());
if (! isset($info['extension']) || $info['extension'] != 'php') {
continue;
}
include $item->getPathName(); include $item->getPathName();
$vars = get_defined_vars(); $vars = get_defined_vars();
foreach ($vars as $var) { foreach ($vars as $var) {
...@@ -111,12 +116,13 @@ class ClassMetadataExporter ...@@ -111,12 +116,13 @@ class ClassMetadataExporter
$classes = array_values($classes); $classes = array_values($classes);
} else { } else {
if ($driver instanceof \Doctrine\ORM\Mapping\Driver\AnnotationDriver) { if ($driver instanceof \Doctrine\ORM\Mapping\Driver\AnnotationDriver) {
$iter = new \FilesystemIterator($dir); $iter = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir),
\RecursiveIteratorIterator::LEAVES_ONLY);
$declared = get_declared_classes(); $declared = get_declared_classes();
foreach ($iter as $item) { foreach ($iter as $item) {
$baseName = $item->getBaseName(); $info = pathinfo($item->getPathName());
if ($baseName[0] == '.') { if (! isset($info['extension']) || $info['extension'] != 'php') {
continue; continue;
} }
require_once $item->getPathName(); require_once $item->getPathName();
...@@ -125,7 +131,7 @@ class ClassMetadataExporter ...@@ -125,7 +131,7 @@ class ClassMetadataExporter
foreach ($declared as $className) { foreach ($declared as $className) {
if ( ! $driver->isTransient($className)) { if ( ! $driver->isTransient($className)) {
$metadata = new ClassMetadataInfo($className); $metadata = new ClassMetadata($className);
$driver->loadMetadataForClass($className, $metadata); $driver->loadMetadataForClass($className, $metadata);
$classes[] = $metadata; $classes[] = $metadata;
} }
......
...@@ -27,6 +27,13 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo, ...@@ -27,6 +27,13 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\OneToManyMapping, Doctrine\ORM\Mapping\OneToManyMapping,
Doctrine\ORM\Mapping\ManyToManyMapping; Doctrine\ORM\Mapping\ManyToManyMapping;
if ( ! class_exists('sfYaml', false)) {
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYaml.class.php';
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYamlDumper.class.php';
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYamlInline.class.php';
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYamlParser.class.php';
}
/** /**
* ClassMetadata exporter for Doctrine YAML mapping files * ClassMetadata exporter for Doctrine YAML mapping files
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment