diff --git a/DataFixtures/AbstractDataHandler.php b/DataFixtures/AbstractDataHandler.php index 691481b..fcfedb2 100644 --- a/DataFixtures/AbstractDataHandler.php +++ b/DataFixtures/AbstractDataHandler.php @@ -10,6 +10,7 @@ namespace Propel\PropelBundle\DataFixtures; +use Propel\Runtime\Map\DatabaseMap; use Propel\Runtime\Propel; use Symfony\Component\Finder\Finder; @@ -22,12 +23,14 @@ abstract class AbstractDataHandler * @var string */ protected $rootDir; + /** * @var \PDO */ protected $con; + /** - * @var \DatabaseMap + * @var DatabaseMap */ protected $dbMap; @@ -45,11 +48,11 @@ abstract class AbstractDataHandler * Default constructor * * @param string $rootDir The root directory. + * @param array $datasources */ - public function __construct($rootDir, Propel $propel, array $datasources) + public function __construct($rootDir, array $datasources) { $this->rootDir = $rootDir; - $this->propel = $propel; $this->datasources = $datasources; } @@ -72,7 +75,7 @@ abstract class AbstractDataHandler return; } - $this->dbMap = $this->propel->getDatabaseMap($connectionName); + $this->dbMap = Propel::getDatabaseMap($connectionName); if (0 === count($this->dbMap->getTables())) { $finder = new Finder(); $files = $finder @@ -94,8 +97,10 @@ abstract class AbstractDataHandler /** * Check if a table is in a database + * * @param string $class * @param string $connectionName + * * @return boolean */ protected function isInDatabase($class, $connectionName) @@ -109,6 +114,8 @@ abstract class AbstractDataHandler * * @param string $path The relative path of the file. * @param string $shortClassName The short class name aka the filename without extension. + * + * @return string|null */ private function guessFullClassName($path, $shortClassName) { diff --git a/DataFixtures/Dumper/AbstractDataDumper.php b/DataFixtures/Dumper/AbstractDataDumper.php index 8b4aabe..2e010e8 100644 --- a/DataFixtures/Dumper/AbstractDataDumper.php +++ b/DataFixtures/Dumper/AbstractDataDumper.php @@ -13,6 +13,7 @@ namespace Propel\PropelBundle\DataFixtures\Dumper; use \Pdo; use Propel\PropelBundle\DataFixtures\AbstractDataHandler; use Propel\Generator\Model\PropelTypes; +use Propel\Runtime\Propel; /** * Abstract class to manage a common logic to dump data. @@ -31,7 +32,7 @@ abstract class AbstractDataDumper extends AbstractDataHandler implements DataDum } $this->loadMapBuilders($connectionName); - $this->con = $this->propel->getConnection($connectionName); + $this->con = Propel::getConnection($connectionName); $array = $this->getDataAsArray($connectionName); $data = $this->transformArrayToData($array); diff --git a/DataFixtures/Loader/AbstractDataLoader.php b/DataFixtures/Loader/AbstractDataLoader.php index 56d2033..bd24e4d 100644 --- a/DataFixtures/Loader/AbstractDataLoader.php +++ b/DataFixtures/Loader/AbstractDataLoader.php @@ -16,6 +16,7 @@ use Propel\Generator\Model\PropelTypes; use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Propel\Runtime\Map\Exception\TableNotFoundException; use Propel\Runtime\Map\TableMap; +use Propel\Runtime\Propel; /** * Abstract class to manage a common logic to load datas. @@ -51,7 +52,7 @@ abstract class AbstractDataLoader extends AbstractDataHandler implements DataLoa $this->deletedClasses = array(); $this->loadMapBuilders($connectionName); - $this->con = $this->propel->getConnection($connectionName); + $this->con = Propel::getConnection($connectionName); try { $this->con->beginTransaction(); @@ -121,7 +122,7 @@ abstract class AbstractDataLoader extends AbstractDataHandler implements DataLoa /** * Loads the data using the generated data model. * - * @param array $data The data to be loaded + * @param array|null $data The data to be loaded */ protected function loadDataFromArray($data = null) { diff --git a/DataFixtures/Loader/YamlDataLoader.php b/DataFixtures/Loader/YamlDataLoader.php index 5b505e1..988b0f6 100644 --- a/DataFixtures/Loader/YamlDataLoader.php +++ b/DataFixtures/Loader/YamlDataLoader.php @@ -31,7 +31,7 @@ class YamlDataLoader extends AbstractDataLoader */ public function __construct($rootDir, ContainerInterface $container) { - parent::__construct($rootDir, $container->get('propel'), $container->getParameter('propel.configuration')); + parent::__construct($rootDir, $container->getParameter('propel.configuration')); $this->container = $container; } diff --git a/Tests/DataFixtures/Dumper/YamlDataDumperTest.php b/Tests/DataFixtures/Dumper/YamlDataDumperTest.php index 7e896c3..fd1173d 100644 --- a/Tests/DataFixtures/Dumper/YamlDataDumperTest.php +++ b/Tests/DataFixtures/Dumper/YamlDataDumperTest.php @@ -38,7 +38,7 @@ class YamlDataDumperTest extends TestCase $filename = $this->getTempFile(); - $loader = new YamlDataDumper(__DIR__.'/../../Fixtures/DataFixtures/Loader', new Propel(), array()); + $loader = new YamlDataDumper(__DIR__.'/../../Fixtures/DataFixtures/Loader', array()); $loader->dump($filename); $expected = <<getTempFile($fixtures); - $loader = new XmlDataLoader(__DIR__.'/../../Fixtures/DataFixtures/Loader', new Propel(), array()); + $loader = new XmlDataLoader(__DIR__.'/../../Fixtures/DataFixtures/Loader', array()); $loader->load(array($filename), 'default'); $books = \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\CoolBookQuery::create()->find($this->con);