Files
apart-moment/local/Beds24/Loop/BookingInfo.php
2021-03-23 13:54:38 +01:00

73 lines
2.4 KiB
PHP

<?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: 13/06/2019 16:01
*/
namespace Beds24\Loop;
use Beds24\Model\Beds24BookingInfo;
use Beds24\Model\Beds24BookingInfoQuery;
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;
/**
* @method int getCartItem()
*/
class BookingInfo extends BaseLoop implements PropelSearchLoopInterface
{
/**
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntTypeArgument('cart_item_id', null, true)
);
}
public function buildModelCriteria()
{
return Beds24BookingInfoQuery::create()
->filterByCartItemId($this->getCartItemId())
;
}
/**
* @param LoopResult $loopResult
* @return LoopResult
* @throws \Propel\Runtime\Exception\PropelException
*/
public function parseResults(LoopResult $loopResult)
{
/** @var Beds24BookingInfo $item */
foreach ($loopResult->getResultDataCollection() as $item) {
$loopResultRow = new LoopResultRow($item);
$loopResultRow
->set('START_DATE', $item->getStartDate())
->set('END_DATE', $item->getEndDate())
->set('NUM_ADULTS', $item->getAdults())
->set('NUM_CHILDREN', $item->getChildren())
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}