Created
February 11, 2020 09:49
-
-
Save fchaussin/faa044ec0dd3da9f0dc57da161998a05 to your computer and use it in GitHub Desktop.
[TYPO3 Extbase] Find By Uid including Hidden and Deleted records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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