* 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(); } }