Initial Commit
This commit is contained in:
71
local/modules/SliderRevolution/Loop/SliderLoop.php
Normal file
71
local/modules/SliderRevolution/Loop/SliderLoop.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
/**
|
||||
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
|
||||
* Date: 25/04/2019 18:57
|
||||
*/
|
||||
namespace SliderRevolution\Loop;
|
||||
|
||||
use Propel\Runtime\Connection\PropelPDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ServiceContainer\ServiceContainerInterface;
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
class SliderLoop extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
public function buildArray()
|
||||
{
|
||||
$query = "select id,alias,title from revslider_sliders where type = ''";
|
||||
|
||||
/** @var PropelPDO $connection */
|
||||
$connection = Propel::getConnection('thelia');
|
||||
|
||||
$statement = $connection->query($query);
|
||||
|
||||
$result = [];
|
||||
|
||||
while ($statement && $row = $statement->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$result[] = [
|
||||
'id' => $row['id'],
|
||||
'alias' => $row['alias'],
|
||||
'title' => $row['title']
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $data) {
|
||||
$loopResultRow = new LoopResultRow($data);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $data['id'])
|
||||
->set("ALIAS", $data['alias'])
|
||||
->set("TITLE", $data['title'])
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user