161 lines
4.7 KiB
PHP
161 lines
4.7 KiB
PHP
<?php
|
|
/**
|
|
* This class has been generated by TheliaStudio
|
|
* For more information, see https://github.com/thelia-modules/TheliaStudio
|
|
*/
|
|
|
|
namespace Contest\Loop\Base;
|
|
|
|
use Propel\Runtime\ActiveQuery\Criteria;
|
|
use Thelia\Core\Template\Element\BaseI18nLoop;
|
|
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 Thelia\Type\BooleanOrBothType;
|
|
use Contest\Model\GameQuery;
|
|
|
|
/**
|
|
* Class Game
|
|
* @package Contest\Loop\Base
|
|
* @author TheliaStudio
|
|
*/
|
|
class Game extends BaseI18nLoop implements PropelSearchLoopInterface
|
|
{
|
|
protected $timestampable = true;
|
|
protected $versionable = true;
|
|
|
|
/**
|
|
* @param LoopResult $loopResult
|
|
*
|
|
* @return LoopResult
|
|
*/
|
|
public function parseResults(LoopResult $loopResult)
|
|
{
|
|
/** @var \Contest\Model\Game $entry */
|
|
foreach ($loopResult->getResultDataCollection() as $entry) {
|
|
$row = new LoopResultRow($entry);
|
|
|
|
$row
|
|
->set("ID", $entry->getId())
|
|
->set("VISIBLE", $entry->getVisible())
|
|
->set("TITLE", $entry->getVirtualColumn("i18n_TITLE"))
|
|
->set("DESCRIPTION", $entry->getVirtualColumn("i18n_DESCRIPTION"))
|
|
;
|
|
|
|
$this->addMoreResults($row, $entry);
|
|
|
|
$loopResult->addRow($row);
|
|
}
|
|
|
|
return $loopResult;
|
|
}
|
|
|
|
/**
|
|
* Definition of loop arguments
|
|
*
|
|
* example :
|
|
*
|
|
* public function getArgDefinitions()
|
|
* {
|
|
* return new ArgumentCollection(
|
|
*
|
|
* Argument::createIntListTypeArgument('id'),
|
|
* new Argument(
|
|
* 'ref',
|
|
* new TypeCollection(
|
|
* new Type\AlphaNumStringListType()
|
|
* )
|
|
* ),
|
|
* Argument::createIntListTypeArgument('category'),
|
|
* Argument::createBooleanTypeArgument('new'),
|
|
* ...
|
|
* );
|
|
* }
|
|
*
|
|
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
|
*/
|
|
protected function getArgDefinitions()
|
|
{
|
|
return new ArgumentCollection(
|
|
Argument::createIntListTypeArgument("id"),
|
|
Argument::createBooleanOrBothTypeArgument("visible", BooleanOrBothType::ANY),
|
|
Argument::createAnyTypeArgument("title"),
|
|
Argument::createEnumListTypeArgument(
|
|
"order",
|
|
[
|
|
"id",
|
|
"id-reverse",
|
|
"visible",
|
|
"visible-reverse",
|
|
"title",
|
|
"title-reverse",
|
|
"description",
|
|
"description-reverse",
|
|
],
|
|
"id"
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* this method returns a Propel ModelCriteria
|
|
*
|
|
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
|
*/
|
|
public function buildModelCriteria()
|
|
{
|
|
$query = new GameQuery();
|
|
$this->configureI18nProcessing($query, ["TITLE", "DESCRIPTION", ]);
|
|
|
|
if (null !== $id = $this->getId()) {
|
|
$query->filterById($id);
|
|
}
|
|
|
|
if (BooleanOrBothType::ANY !== $visible = $this->getVisible()) {
|
|
$query->filterByVisible($visible);
|
|
}
|
|
|
|
if (null !== $title = $this->getTitle()) {
|
|
$title = array_map("trim", explode(",", $title));
|
|
$query->filterByTitle($title);
|
|
}
|
|
|
|
foreach ($this->getOrder() as $order) {
|
|
switch ($order) {
|
|
case "id":
|
|
$query->orderById();
|
|
break;
|
|
case "id-reverse":
|
|
$query->orderById(Criteria::DESC);
|
|
break;
|
|
case "visible":
|
|
$query->orderByVisible();
|
|
break;
|
|
case "visible-reverse":
|
|
$query->orderByVisible(Criteria::DESC);
|
|
break;
|
|
case "title":
|
|
$query->addAscendingOrderByColumn("i18n_TITLE");
|
|
break;
|
|
case "title-reverse":
|
|
$query->addDescendingOrderByColumn("i18n_TITLE");
|
|
break;
|
|
case "description":
|
|
$query->addAscendingOrderByColumn("i18n_DESCRIPTION");
|
|
break;
|
|
case "description-reverse":
|
|
$query->addDescendingOrderByColumn("i18n_DESCRIPTION");
|
|
break;
|
|
}
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
protected function addMoreResults(LoopResultRow $row, $entryObject)
|
|
{
|
|
}
|
|
}
|