create base loop for delivery and payment entities

This commit is contained in:
Manuel Raynaud
2013-09-06 17:40:49 +02:00
parent 2fda14cfeb
commit a3b7e977da

View File

@@ -0,0 +1,109 @@
<?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 Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\ModuleQuery;
/**
* Class Delivery
* @package Thelia\Core\Template\Loop
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class BaseSpecificModule extends BaseLoop {
public $timestampable = true;
public $versionable = true;
/**
*
* define all args used in your loop
*
*
* example :
*
* public function getArgDefinitions()
* {
* return new ArgumentCollection(
* Argument::createIntListTypeArgument('id'),
* new Argument(
* 'ref',
* new TypeCollection(
* new Type\AlphaNumStringListType()
* )
* ),
* Argument::createIntListTypeArgument('category'),
* Argument::createBooleanTypeArgument('new'),
* Argument::createBooleanTypeArgument('promo'),
* Argument::createFloatTypeArgument('min_price'),
* Argument::createFloatTypeArgument('max_price'),
* Argument::createIntTypeArgument('min_stock'),
* Argument::createFloatTypeArgument('min_weight'),
* Argument::createFloatTypeArgument('max_weight'),
* Argument::createBooleanTypeArgument('current'),
*
* );
* }
*
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntTypeArgument('id'),
Argument::createIntListTypeArgument('exclude')
);
}
/**
*
* this function have to be implement in your own loop class.
*
* All loops parameters can be accesible via getter.
*
* for example, ref parameter is accessible through getRef method
*
* @param $pagination
*
* @return \Thelia\Model\ModuleQuery
*/
public function exec(&$pagination)
{
$search = ModuleQuery::create();
if(null !== $id = $this->getId())
{
$search->filterById($id);
}
if (null !== $exclude = $this->getExclude()) {
$search->filterById($exclude, Criteria::NOT_IN);
}
return $search;
}
}