create area loop and shipping conf events name

This commit is contained in:
Manuel Raynaud
2013-10-10 16:18:51 +02:00
parent 6bfca2c6b4
commit 8856cec55c
7 changed files with 330 additions and 85 deletions

View File

@@ -232,6 +232,12 @@ final class TheliaEvents
const BEFORE_UPDATECOUNTRY = "action.before_updateCountry";
const AFTER_UPDATECOUNTRY = "action.after_updateCountry";
// -- SHIPPING CONFIGURATION MANAGEMENT
const SHIPPING_CREATE = 'action.createShipping';
const SHIPPING_UPDATE = 'action.updateShipping';
const SHIPPING_DELETE = 'action.deleteShipping';
// -- Categories Associated Content ----------------------------------------
const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent";

View File

@@ -0,0 +1,124 @@
<?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\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\AreaQuery;
/**
* Class Area
* @package Thelia\Core\Template\Loop
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Area extends BaseLoop
{
public $timestampable = 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::createIntListTypeArgument('id')
);
}
/**
*
* this function have to be implement in your own loop class.
*
* All loops parameters can be accessible via getter.
*
* for example, ref parameter is accessible through getRef method
*
* @param $pagination
*
* @return mixed
*/
public function exec(&$pagination)
{
$id = $this->getId();
$search = AreaQuery::create();
if ($id) {
$search->filterById($id, Criteria::IN);
}
$areas = $this->search($search, $pagination);
$loopResult = new LoopResult($areas);
foreach ($areas as $area) {
$loopResultRow = new LoopResultRow($loopResult, $area, $this->versionable, $this->timestampable, $this->countable);
$loopResultRow
->set('ID', $area->getId())
->set('NAME', $area->getName())
->set('POSTAGE', $area->getPostage())
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}