create Delivery loop

This commit is contained in:
Manuel Raynaud
2013-09-06 18:41:44 +02:00
parent a3b7e977da
commit b067ef7dcc
11 changed files with 224 additions and 29 deletions

View File

@@ -23,7 +23,7 @@
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\ModuleQuery;
@@ -34,9 +34,8 @@ use Thelia\Model\ModuleQuery;
* @package Thelia\Core\Template\Loop
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class BaseSpecificModule extends BaseLoop {
class BaseSpecificModule extends BaseI18nLoop {
public $timestampable = true;
public $versionable = true;
/**
*
@@ -106,4 +105,5 @@ class BaseSpecificModule extends BaseLoop {
return $search;
}
}

View File

@@ -0,0 +1,82 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument;
/**
* Class Delivery
* @package Thelia\Core\Template\Loop
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Delivery extends BaseSpecificModule
{
public function getArgDefinitions()
{
$collection = parent::getArgDefinitions();
$collection->addArgument(
Argument::createIntTypeArgument("country")
);
return $collection;
}
public function exec(&$pagination)
{
$search = parent::exec($pagination);
/* manage translations */
$locale = $this->configureI18nProcessing($search);
/* perform search */
$deliveryModules = $this->search($search, $pagination);
$loopResult = new LoopResult($deliveryModules);
foreach ($deliveryModules as $deliveryModule) {
$loopResultRow = new LoopResultRow($loopResult, $deliveryModule, $this->versionable, $this->timestampable, $this->countable);
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
$moduleInstance = $moduleReflection->newInstance();
$moduleInstance->setRequest($this->request);
$moduleInstance->setDispatcher($this->dispatcher);
$loopResultRow
->set('ID', $deliveryModule->getId())
->set('TITLE', $deliveryModule->getVirtualColumn('i18n_TITLE'))
->set('CHAPO', $deliveryModule->getVirtualColumn('i18n_CHAPO'))
->set('DESCRIPTION', $deliveryModule->getVirtualColumn('i18n_DESCRIPTION'))
->set('POSTSCRIPTUM', $deliveryModule->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set('PRICE', $moduleInstance->calculate($this->getCountry()))
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -111,7 +111,7 @@ class Thelia extends Kernel
try {
$defintion = new Definition();
$defintion->setClass($module->getCode() ."\\". ucfirst($module->getCode()));
$defintion->setClass($module->getFullNamespace());
$defintion->addMethodCall("setContainer", array('service_container'));
$container->setDefinition(