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
$printer->writeln('You must include a value for all four options: --from, --to and --dest', 'ERROR');
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.');
return false;
}
......@@ -133,7 +133,12 @@ class ConvertMappingTask extends AbstractTask
{
throw new \InvalidArgumentException(sprintf('No schema mapping files found in "%s"', $path));
}
$info = pathinfo($files[0]);
return $info['extension'];
$contents = file_get_contents($files[0]);
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
$classes = array();
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();
foreach ($iter as $item) {
$baseName = $item->getBaseName();
if ($baseName[0] == '.') {
$info = pathinfo($item->getPathName());
if (! isset($info['extension']) || $info['extension'] != 'php') {
continue;
}
require_once $item->getPathName();
......
......@@ -96,9 +96,14 @@ class ClassMetadataExporter
foreach ($this->_mappingDirectories as $d) {
list($dir, $driver) = $d;
if ($driver == 'php') {
$iter = new \FilesystemIterator($dir);
$iter = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir),
\RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($iter as $item) {
$info = pathinfo($item->getPathName());
if (! isset($info['extension']) || $info['extension'] != 'php') {
continue;
}
include $item->getPathName();
$vars = get_defined_vars();
foreach ($vars as $var) {
......@@ -111,12 +116,13 @@ class ClassMetadataExporter
$classes = array_values($classes);
} else {
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();
foreach ($iter as $item) {
$baseName = $item->getBaseName();
if ($baseName[0] == '.') {
$info = pathinfo($item->getPathName());
if (! isset($info['extension']) || $info['extension'] != 'php') {
continue;
}
require_once $item->getPathName();
......@@ -125,7 +131,7 @@ class ClassMetadataExporter
foreach ($declared as $className) {
if ( ! $driver->isTransient($className)) {
$metadata = new ClassMetadataInfo($className);
$metadata = new ClassMetadata($className);
$driver->loadMetadataForClass($className, $metadata);
$classes[] = $metadata;
}
......
......@@ -27,6 +27,13 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\OneToManyMapping,
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
*
......
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