country loop
coutryI18n data
This commit is contained in:
@@ -45,8 +45,9 @@ abstract class BaseLoop
|
||||
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
|
||||
*/
|
||||
protected $dispatcher;
|
||||
|
||||
/**
|
||||
* @var Thelia\Core\Security\SecurityContext
|
||||
* @var SecurityContext
|
||||
*/
|
||||
protected $securityContext;
|
||||
|
||||
@@ -56,9 +57,9 @@ abstract class BaseLoop
|
||||
/**
|
||||
* Create a new Loop
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
|
||||
* @param Thelia\Core\Security\SecurityContext $securityContext
|
||||
* @param Request $request
|
||||
* @param EventDispatcherInterface $dispatcher
|
||||
* @param SecurityContext $securityContext
|
||||
*/
|
||||
public function __construct(Request $request, EventDispatcherInterface $dispatcher, SecurityContext $securityContext)
|
||||
{
|
||||
@@ -66,20 +67,20 @@ abstract class BaseLoop
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->securityContext = $securityContext;
|
||||
|
||||
$this->args = $this->getArgDefinitions()->addArguments($this->getDefaultArgs());
|
||||
$this->args = $this->getArgDefinitions()->addArguments($this->getDefaultArgs(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define common loop arguments
|
||||
*
|
||||
* @return an array ofL \Thelia\Core\Template\Loop\Argument\Argument
|
||||
* @return Argument[]
|
||||
*/
|
||||
protected function getDefaultArgs()
|
||||
{
|
||||
return array(
|
||||
Argument::createIntTypeArgument('offset', 0),
|
||||
Argument::createIntTypeArgument('page'),
|
||||
Argument::createIntTypeArgument('limit', 10),
|
||||
Argument::createIntTypeArgument('offset', 0),
|
||||
Argument::createIntTypeArgument('page'),
|
||||
Argument::createIntTypeArgument('limit', 10),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,7 +88,9 @@ abstract class BaseLoop
|
||||
* Provides a getter to loop parameters
|
||||
*
|
||||
* @param string $name the methode name (only getArgname is supported)
|
||||
* @param mixed $arguments this parameter is ignored
|
||||
* @param $arguments this parameter is ignored
|
||||
*
|
||||
* @return null
|
||||
* @throws \InvalidArgumentException if the parameter is unknown or the method name is not supported.
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
|
||||
@@ -115,9 +115,6 @@ class Address extends BaseLoop
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($addresses as $address) {
|
||||
|
||||
if ($this->not_empty && $address->countAllProducts() == 0) continue;
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $address->getId());
|
||||
$loopResultRow->set("NAME", $address->getName());
|
||||
|
||||
@@ -34,7 +34,7 @@ class ArgumentCollection implements \Iterator
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->addArguments(func_get_args());
|
||||
$this->addArguments(func_get_args(), true);
|
||||
}
|
||||
|
||||
public function hasKey($key) {
|
||||
@@ -51,14 +51,15 @@ class ArgumentCollection implements \Iterator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $argumentList
|
||||
* @param array $argumentList
|
||||
* @param $force
|
||||
*
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
public function addArguments(array $argumentList)
|
||||
public function addArguments(array $argumentList, $force = true)
|
||||
{
|
||||
foreach($argumentList as $argument) {
|
||||
$this->addArgument($argument);
|
||||
$this->addArgument($argument, $force);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -66,11 +67,16 @@ class ArgumentCollection implements \Iterator
|
||||
|
||||
/**
|
||||
* @param Argument $argument
|
||||
* @param $force
|
||||
*
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
public function addArgument(Argument $argument)
|
||||
public function addArgument(Argument $argument, $force = true)
|
||||
{
|
||||
if(isset($this->arguments[$argument->name]) && ! $force) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->arguments[$argument->name] = $argument;
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -32,7 +32,7 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\CustomerCountryQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
@@ -54,7 +54,11 @@ class Country extends BaseLoop
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id')
|
||||
Argument::createIntTypeArgument('limit', 500), // overwrite orginal param to increase the limit
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('area'),
|
||||
Argument::createBooleanTypeArgument('with_area'),
|
||||
Argument::createIntListTypeArgument('exclude')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -65,7 +69,7 @@ class Country extends BaseLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = CustomerCountryQuery::create();
|
||||
$search = CountryQuery::create();
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -73,6 +77,20 @@ class Country extends BaseLoop
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$area = $this->getArea();
|
||||
|
||||
if (null !== $area) {
|
||||
$search->filterByAreaId($area, Criteria::IN);
|
||||
}
|
||||
|
||||
$withArea = $this->getWith_area();
|
||||
|
||||
if (true === $withArea) {
|
||||
$search->filterByAreaId(null, Criteria::ISNOTNULL);
|
||||
} elseif (false == $withArea) {
|
||||
$search->filterByAreaId(null, Criteria::ISNULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
@@ -84,21 +102,23 @@ class Country extends BaseLoop
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
|
||||
$search->orderByPosition();
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\CountryI18nTableMap::TITLE);
|
||||
|
||||
$countrys = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($countrys as $country) {
|
||||
|
||||
if ($this->not_empty && $country->countAllProducts() == 0) continue;
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $country->getId());
|
||||
$loopResultRow->set("DEFAULT", $country->getByDefault());
|
||||
$loopResultRow->set("SHORT", $country->getShort());
|
||||
$loopResultRow->set("LONG", $country->getLong());
|
||||
$loopResultRow->set("AREA", $country->getAreaId());
|
||||
$loopResultRow->set("TITLE", $country->getTitle());
|
||||
$loopResultRow->set("CHAPO", $country->getChapo());
|
||||
$loopResultRow->set("DESCRIPTION", $country->getDescription());
|
||||
$loopResultRow->set("POSTSCRIPTUM", $country->getPostscriptum());
|
||||
$loopResultRow->set("ISOCODE", $country->getIsocode());
|
||||
$loopResultRow->set("ISOALPHA2", $country->getIsoalpha2());
|
||||
$loopResultRow->set("ISOALPHA3", $country->getIsoalpha3());
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
@@ -118,9 +118,6 @@ class Customer extends BaseLoop
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
|
||||
if ($this->not_empty && $customer->countAllProducts() == 0) continue;
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $customer->getId());
|
||||
$loopResultRow->set("REF", $customer->getRef());
|
||||
|
||||
@@ -91,9 +91,6 @@ class Title extends BaseLoop
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($titles as $title) {
|
||||
|
||||
if ($this->not_empty && $title->countAllProducts() == 0) continue;
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $title->getId());
|
||||
$loopResultRow->set("DEFAULT", $title->getByDefault());
|
||||
|
||||
Reference in New Issue
Block a user