|
<?php
|
|
|
|
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction;
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\FrontendGroupRestriction;
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionInterface;
|
|
use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction;
|
|
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
|
|
|
|
/**
|
|
* Custom TYPO3 DB Query Parser
|
|
*/
|
|
class Typo3DbQueryParser extends \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser
|
|
{
|
|
/**
|
|
* Mappings from TCA enable fields to query restrictions
|
|
*
|
|
* @var QueryRestrictionInterface[]
|
|
*/
|
|
protected static $enableFieldsRestrictionMappings = [
|
|
'delete' => DeletedRestriction::class,
|
|
'disabled' => HiddenRestriction::class,
|
|
'starttime' => StartTimeRestriction::class,
|
|
'endtime' => EndTimeRestriction::class,
|
|
'fe_group' => FrontendGroupRestriction::class,
|
|
];
|
|
|
|
/**
|
|
* Returns a ready to be executed QueryBuilder object, based on the query
|
|
*
|
|
* @param QueryInterface $query
|
|
*
|
|
* @return QueryBuilder
|
|
*/
|
|
public function convertQueryToDoctrineQueryBuilder(QueryInterface $query)
|
|
{
|
|
$queryBuilder = parent::convertQueryToDoctrineQueryBuilder($query);
|
|
|
|
if ($query->getQuerySettings()->getIgnoreEnableFields()) {
|
|
if (!empty($ignoreEnableFields = $query->getQuerySettings()->getEnableFieldsToBeIgnored())) {
|
|
foreach ($ignoreEnableFields as $ignoreEnableField) {
|
|
if (!empty(static::$enableFieldsRestrictionMappings[$ignoreEnableField])) {
|
|
$queryBuilder->getRestrictions()
|
|
->removeByType(static::$enableFieldsRestrictionMappings[$ignoreEnableField]);
|
|
}
|
|
}
|
|
} else {
|
|
$queryBuilder->getRestrictions()->removeAll();
|
|
}
|
|
}
|
|
|
|
return $queryBuilder;
|
|
}
|
|
}
|