migrte propel to propel 2

This commit is contained in:
Manuel Raynaud
2013-07-04 19:31:09 +02:00
parent dcb3baaf4c
commit 5fda702b8d
531 changed files with 516 additions and 287452 deletions

View File

@@ -26,6 +26,7 @@ namespace Thelia\Core\Template\Element;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Propel\Runtime\ActiveQuery\ModelCriteria;
/**
*
@@ -78,7 +79,7 @@ abstract class BaseLoop
*
* @return array|mixed|\PropelModelPager|\PropelObjectCollection
*/
public function search(\ModelCriteria $search, &$pagination = null)
public function search(ModelCriteria $search, &$pagination = null)
{
if($this->page !== null) {
return $this->searchWithPagination($search, $pagination);
@@ -92,7 +93,7 @@ abstract class BaseLoop
*
* @return array|mixed|\PropelObjectCollection
*/
public function searchWithOffset(\ModelCriteria $search)
public function searchWithOffset(ModelCriteria $search)
{
if($this->limit >= 0) {
$search->limit($this->limit);
@@ -108,7 +109,7 @@ abstract class BaseLoop
*
* @return array|\PropelModelPager
*/
public function searchWithPagination(\ModelCriteria $search, &$pagination)
public function searchWithPagination(ModelCriteria $search, &$pagination)
{
$pagination = $search->paginate($this->page, $this->limit);

View File

@@ -23,6 +23,7 @@
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
@@ -108,7 +109,7 @@ class Category extends BaseLoop
$search = CategoryQuery::create();
if (!is_null($this->id)) {
$search->filterById(explode(',', $this->id), \Criteria::IN);
$search->filterById(explode(',', $this->id), ModelCriteria::IN);
}
if (!is_null($this->parent)) {
@@ -118,11 +119,11 @@ class Category extends BaseLoop
if ($this->current == 1) {
$search->filterById($this->request->get("category_id"));
} elseif (null !== $this->current && $this->current == 0) {
$search->filterById($this->request->get("category_id"), \Criteria::NOT_IN);
$search->filterById($this->request->get("category_id"), ModelCriteria::NOT_IN);
}
if (!is_null($this->exclude)) {
$search->filterById(explode(",", $this->exclude), \Criteria::NOT_IN);
$search->filterById(explode(",", $this->exclude), ModelCriteria::NOT_IN);
}
if (!is_null($this->link)) {
@@ -156,7 +157,7 @@ class Category extends BaseLoop
*
* @todo : verify here if we want results for row without translations.
*/
$search->joinWithI18n($this->request->getSession()->get('locale', 'en_US'), \Criteria::INNER_JOIN);
$search->joinWithI18n('en_US');
$categories = $this->search($search, $pagination);

View File

@@ -46,8 +46,8 @@ use Thelia\Core\TheliaContainerBuilder;
use Thelia\Core\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\Config\FileLocator;
use Propel;
use PropelConfiguration;
use Propel\Runtime\Propel;
use Propel\Runtime\Connection\ConnectionManagerSingle;
class Thelia extends Kernel
{
@@ -71,7 +71,7 @@ class Thelia extends Kernel
return ;
}
if (! Propel::isInit()) {
/* if (! Propel::isInit()) {
$definePropel = new DefinePropel(new DatabaseConfiguration(),
Yaml::parse(THELIA_ROOT . '/local/config/database.yml'));
@@ -97,7 +97,16 @@ class Thelia extends Kernel
}
Propel::initialize();
}
}*/
$definePropel = new DefinePropel(new DatabaseConfiguration(),
Yaml::parse(THELIA_ROOT . '/local/config/database.yml'));
$propelConfig = $definePropel->getConfig();
$serviceContainer = Propel::getServiceContainer();
$serviceContainer->setAdapterClass('thelia', 'mysql');
$manager = new ConnectionManagerSingle();
$manager->setConfiguration($definePropel->getConfig());
$serviceContainer->setConnectionManager('thelia', $manager);
}
/**