Shure, i created a normal repository and inserted a function, that will fetch the hidden records:
/**
* Finds records with the given emailWildcard, includes hidden records
*
* @param string $emailWildcard
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findByEmailWildcardWithHidden($emailWildcard){
$query = $this->createQuery();
$querySettings = $query->getQuerySettings();
$querySettings->setIgnoreEnableFields(TRUE);
$querySettings->setEnableFieldsToBeIgnored(array('hidden'));
$query->setQuerySettings($querySettings);
return $query->matching($query->equals('emailWildcard', $emailWildcard))->execute();
}
I excluded the storage page by default:
/**
* Initializes the blacklist repository
*/
public function initializeObject(){
/** @var $defaultQuerySettings \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings */
$defaultQuerySettings = $this->objectManager->get('\\TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
// don't add the pid constraint
$defaultQuerySettings->setRespectStoragePage(FALSE);
$this->setDefaultQuerySettings($defaultQuerySettings);
}
And called the repository method in the controller like so:
$blacklistEntry = $this->blacklistRepository->findByEmailWildcardWithHidden($vote->getEmail());
if($blacklistEntry->count() <= 0){
$blacklistEntry = $this->objectManager->get('\EngineProductions\EpAwards\Domain\Model\Blacklist');
$blacklistEntry->setHidden(TRUE);
$blacklistEntry->setEmailWildcard($vote->getEmail());
$this->blacklistRepository->add($blacklistEntry);
}
I would like to check, if a blacklist entry for the submitted email address is present, even if it is hidden. In my opinion this should work, because i excluded the hidden field inside the repository find-method, but when the query fires, inside the getFrontendConstraintStatement method, the following line leads to the exclusion of hidden fields.
$statement .= $this->getPageRepository()->enableFields($tableName, -1, array_combine($enableFieldsToBeIgnored, $enableFieldsToBeIgnored));
It seems the function enableFields inside of \TYPO3\CMS\Frontend\Page\PageRepository does not recognize the hidden field exclusion, because it is only listening to the $show_hidden parameter, that is set to - 1. So i can only show the hidden records, if i switch $GLOBALS['TSFE']->showHiddenRecords to true, but i don't want to show all hidden records globaly, but only the ones, that i select with my query in the repository.