Merge pull request #5 from havvg/2.0

remove Propel\Runtime\Propel dependency
This commit is contained in:
Kévin Gomez 2014-04-26 12:07:16 -04:00
commit 8fb8e3eb0c
6 changed files with 19 additions and 10 deletions

View file

@ -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)
{

View file

@ -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);

View file

@ -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)
{

View file

@ -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;
}

View file

@ -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 = <<<YAML

View file

@ -35,7 +35,7 @@ XML;
$filename = $this->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);