140 lines
5.3 KiB
PHP
140 lines
5.3 KiB
PHP
<?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 View\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\Element\PropelSearchLoopInterface;
|
|
use Thelia\Core\Template\Loop\Argument\Argument;
|
|
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
|
use View\Model\ViewQuery;
|
|
|
|
/**
|
|
* Class Commentaire
|
|
* @package Commentaire\Loop
|
|
* @author manuel raynaud <mraynaud@openstudio.fr>
|
|
*/
|
|
class View extends BaseLoop implements PropelSearchLoopInterface
|
|
{
|
|
protected $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'),
|
|
Argument::createAnyTypeArgument('view'),
|
|
Argument::createAnyTypeArgument('source'),
|
|
Argument::createIntTypeArgument('source_id')
|
|
);
|
|
}
|
|
|
|
/**
|
|
* this method returns a Propel ModelCriteria
|
|
*
|
|
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
|
*/
|
|
public function buildModelCriteria()
|
|
{
|
|
$search = ViewQuery::create();
|
|
|
|
if (null !== $id = $this->getId()) {
|
|
$search->filterById($id, Criteria::IN);
|
|
}
|
|
|
|
if (null !== $view = $this->getView()) {
|
|
$search->filterByView($view, Criteria::IN);
|
|
}
|
|
|
|
if (null !== $source = $this->getSource()) {
|
|
$search->filterBySource($source, Criteria::IN);
|
|
}
|
|
|
|
if (null !== $source_id = $this->getSourceId()) {
|
|
$search->filterBySourceId($source_id, Criteria::IN);
|
|
}
|
|
|
|
return $search;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param LoopResult $loopResult
|
|
*
|
|
* @return LoopResult
|
|
*/
|
|
public function parseResults(LoopResult $loopResult)
|
|
{
|
|
/** @var \View\Model\View $view */
|
|
foreach ($loopResult->getResultDataCollection() as $view) {
|
|
$loopResultRow = new LoopResultRow($view);
|
|
|
|
$loopResultRow
|
|
->set('ID', $view->getId())
|
|
->set('SOURCE_ID', $view->getSourceId())
|
|
->set('SOURCE', $view->getSource())
|
|
->set('VIEW', $view->getView())
|
|
->set('SUBTREE_VIEW', $view->getSubtreeView())
|
|
->set('CHILDREN_VIEW', $view->getChildrenView())
|
|
;
|
|
|
|
$loopResult->addRow($loopResultRow);
|
|
}
|
|
|
|
return $loopResult;
|
|
}
|
|
} |