Permalink
Browse files

Avoid duplicating fixtures path

  • Loading branch information...
1 parent 234f874 commit 0f78f2b8755363c9c3c8725e6a9f9dfeacac1500 Romain Pouclet committed Apr 6, 2012
Showing with 13 additions and 2 deletions.
  1. +13 −2 Command/FixturesLoadCommand.php
@@ -16,6 +16,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
+use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Propel\PropelBundle\Command\AbstractPropelCommand;
use Propel\PropelBundle\DataFixtures\Loader\YamlDataLoader;
@@ -128,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
->getContainer()
->get('kernel')
->getBundle(substr($input->getArgument('bundle'), 1));
- $this->absoluteFixturesPath = $this->bundle->getPath() . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'fixtures';
+ $this->absoluteFixturesPath = $this->getFixturesPath($this->bundle);
} else {
$this->absoluteFixturesPath = realpath($this->getApplication()->getKernel()->getRootDir() . '/../' . $input->getOption('dir'));
}
@@ -321,11 +322,21 @@ protected function getFixtureFiles($type = 'sql', $in = null)
$finalFixtureFiles = array();
foreach ($files as $file) {
- $fixtureFilePath = str_replace($this->bundle->getPath(). DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR, '', $file->getRealPath());
+ $fixtureFilePath = str_replace($this->getFixturesPath($this->bundle) . DIRECTORY_SEPARATOR, '', $file->getRealPath());
$logicalName = sprintf('@%s/Resources/fixtures/%s', $this->bundle->getName(), $fixtureFilePath);
$finalFixtureFiles[] = new \SplFileInfo($this->getFileLocator()->locate($logicalName));
}
return new \ArrayIterator($finalFixtureFiles);
}
+
+ /**
+ * Returns the path the command will look into to find fixture files
+ *
+ * @return String
+ */
+ protected function getFixturesPath(BundleInterface $bundle)
+ {
+ return $bundle->getPath().DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'fixtures';
+ }
}

0 comments on commit 0f78f2b

Please sign in to comment.