Move constant
This commit is contained in:
@@ -30,9 +30,6 @@ namespace EP\EpProducts\Domain\Model;
|
|||||||
class Date extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
class Date extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
const DURATION_SHORT = 4;
|
|
||||||
const DURATION_LONG = 5;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ class FilterSettings implements \JsonSerializable
|
|||||||
const DESTINATION_TYPE_HOTEL = 'hotel';
|
const DESTINATION_TYPE_HOTEL = 'hotel';
|
||||||
const DESTINATION_TYPE_PRODUCT = 'product';
|
const DESTINATION_TYPE_PRODUCT = 'product';
|
||||||
|
|
||||||
|
const DURATION_SHORT = 4;
|
||||||
|
const DURATION_LONG = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ namespace EP\EpProducts\Domain\Repository;
|
|||||||
* This copyright notice MUST APPEAR in all copies of the script!
|
* This copyright notice MUST APPEAR in all copies of the script!
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
use EP\EpProducts\Domain\Model\Date;
|
|
||||||
use EP\EpProducts\Domain\Model\FilterSettings;
|
use EP\EpProducts\Domain\Model\FilterSettings;
|
||||||
use EP\EpProducts\Traits\DbConnectionTrait;
|
use EP\EpProducts\Traits\DbConnectionTrait;
|
||||||
use TYPO3\CMS\Core\Database\Connection;
|
use TYPO3\CMS\Core\Database\Connection;
|
||||||
@@ -47,6 +46,7 @@ abstract class AbstractRepository extends \TYPO3\CMS\Extbase\Persistence\Reposit
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param array $uids
|
||||||
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
|
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
|
||||||
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
|
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
|
||||||
*/
|
*/
|
||||||
@@ -170,7 +170,7 @@ abstract class AbstractRepository extends \TYPO3\CMS\Extbase\Persistence\Reposit
|
|||||||
// Price range
|
// Price range
|
||||||
$priceRange = (int) $filterSettings->getPriceRange();
|
$priceRange = (int) $filterSettings->getPriceRange();
|
||||||
if ($priceRange > 0) {
|
if ($priceRange > 0) {
|
||||||
list($priceMin, $priceMax) = FilterSettings::$priceRanges[$priceRange];
|
[ $priceMin, $priceMax ] = FilterSettings::$priceRanges[$priceRange];
|
||||||
$query
|
$query
|
||||||
->andWhere('date.min_price >= :priceMin')
|
->andWhere('date.min_price >= :priceMin')
|
||||||
->andWhere('date.min_price < :priceMax')
|
->andWhere('date.min_price < :priceMax')
|
||||||
@@ -187,12 +187,12 @@ abstract class AbstractRepository extends \TYPO3\CMS\Extbase\Persistence\Reposit
|
|||||||
protected function addDurationFilterConditions(QueryBuilder $query, FilterSettings $filterSettings)
|
protected function addDurationFilterConditions(QueryBuilder $query, FilterSettings $filterSettings)
|
||||||
{
|
{
|
||||||
// Duration
|
// Duration
|
||||||
if ((int) $filterSettings->getNights() === Date::DURATION_SHORT) {
|
if ((int) $filterSettings->getNights() === FilterSettings::DURATION_SHORT) {
|
||||||
$query
|
$query
|
||||||
->andWhere('date.nights <= :nights')
|
->andWhere('date.nights <= :nights')
|
||||||
->setParameter('nights', $filterSettings->getNights())
|
->setParameter('nights', $filterSettings->getNights())
|
||||||
;
|
;
|
||||||
} elseif ((int) $filterSettings->getNights() === Date::DURATION_LONG) {
|
} elseif ((int) $filterSettings->getNights() === FilterSettings::DURATION_LONG) {
|
||||||
$query
|
$query
|
||||||
->andWhere('date.nights >= :nights')
|
->andWhere('date.nights >= :nights')
|
||||||
->setParameter('nights', $filterSettings->getNights())
|
->setParameter('nights', $filterSettings->getNights())
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class FilterService implements SingletonInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Nights
|
// Nights
|
||||||
$duration = (int) $row['nights'] <= 4 ? Date::DURATION_SHORT : Date::DURATION_LONG;
|
$duration = (int) $row['nights'] <= 4 ? FilterSettings::DURATION_SHORT : FilterSettings::DURATION_LONG;
|
||||||
|
|
||||||
if (!in_array($duration, $nights)) {
|
if (!in_array($duration, $nights)) {
|
||||||
$nights[] = $duration;
|
$nights[] = $duration;
|
||||||
|
|||||||
Reference in New Issue
Block a user