Skip to content

Instantly share code, notes, and snippets.

@fchaussin
Created February 11, 2020 09:49
Show Gist options
  • Save fchaussin/faa044ec0dd3da9f0dc57da161998a05 to your computer and use it in GitHub Desktop.
Save fchaussin/faa044ec0dd3da9f0dc57da161998a05 to your computer and use it in GitHub Desktop.
[TYPO3 Extbase] Find By Uid including Hidden and Deleted records
/**
* Find a record by uid even if it is hidden or deleted
*
* @param int $uid
* @param int|array $pid
* @return object
*/
public function findByUidInAllRecordsByUid($uid, $pid=false)
{
$query = $this->createQuery();
$query->getQuerySettings()
->setIgnoreEnableFields(true)
->setIncludeDeleted(true)
->setRespectStoragePage(false);
if($pid){
if( is_array($pid) ){
$query->getQuerySettings()->setStoragePageIds( $pid );
}
elseif( is_integer($pid) ){
$query->getQuerySettings()->setStoragePageIds( [$pid] );
}
}
$query->matching($query->equals('uid', $uid));
return $query->execute()->getFirst();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment