php - How to get and filter all referenced FAL files with extbase -



php - How to get and filter all referenced FAL files with extbase -

i'm working on extension, displays files referenced in sys_file_reference. there possibility categorize , filter every file based on new custom property in sys_file_metadata.

what's best way , filter referenced files typo3\cms\core\resource\file model?

with help of typo3\cms\core\resource\filerepository able file models including metadata. repository expects uid retrieve file. fetch referenced files repository , pass them findfilereferencebyuid() method.

class documentrepository extends \typo3\cms\extbase\persistence\repository { /** * disables pid constraint * * @return void */ public function initializeobject() { $querysettings = $this->objectmanager->create('typo3\\cms\\extbase\\persistence\\generic\\typo3querysettings'); $querysettings->setrespectstoragepage(false); $this->setdefaultquerysettings($querysettings); } /** * finds referenced documents returning them file modules * * @return void */ public function findallreferenced() { $filerepository = \typo3\cms\core\utility\generalutility::makeinstance('typo3\\cms\\core\\resource\\filerepository'); $query = $this->createquery(); $documents = $query->execute(); $references = array(); foreach ($documents $document) { $references[] = $filerepository->findfilereferencebyuid($document->getuid()); } homecoming $references; } }

is there simpler way , how implement filter?

update

for bypass extbase , utilize database connection directly. typo3 internally lot.

/** * finds referenced documents returning them file models * * @return array */ public function findallreferenced() { $rows = $this->getdatabaseconnection()->exec_selectgetrows( 'sys_file sf left bring together tt_content ttc on ttc.header_link=concat("file:", sf.uid) left bring together sys_file_reference ref on sf.uid=ref.uid_local left bring together sys_file_metadata meta on sf.uid=meta.file', '((ttc.uid not null , ttc.hidden = 0 , ttc.deleted = 0) or (ref.uid not null , ref.hidden = 0 , ref.deleted = 0))', 'sf.uid' ); $documents = array(); if (!empty($rows)) { foreach ($rows $row) { $documents[] = $this->createdomainobject($row); } } homecoming $documents; }

php typo3 extbase typo3-6.2.x

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -