TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
CategoryBasedFileCollection.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Resource\Collection;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
26 {
30  protected static $storageTableName = 'sys_file_collection';
31 
35  protected static $type = 'categories';
36 
40  protected static $itemsCriteriaField = 'category';
41 
45  protected $itemTableName = 'sys_category';
46 
52  public function loadContents()
53  {
54  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_category');
55  $queryBuilder->getRestrictions()->removeAll();
56  $statement = $queryBuilder->select('sys_file_metadata.file')
57  ->from('sys_category')
58  ->join(
59  'sys_category',
60  'sys_category_record_mm',
61  'sys_category_record_mm',
62  $queryBuilder->expr()->eq(
63  'sys_category_record_mm.uid_local',
64  $queryBuilder->quoteIdentifier('sys_category.uid')
65  )
66  )
67  ->join(
68  'sys_category_record_mm',
69  'sys_file_metadata',
70  'sys_file_metadata',
71  $queryBuilder->expr()->eq(
72  'sys_category_record_mm.uid_foreign',
73  $queryBuilder->quoteIdentifier('sys_file_metadata.uid')
74  )
75  )
76  ->where(
77  $queryBuilder->expr()->eq(
78  'sys_category.uid',
79  $queryBuilder->createNamedParameter($this->getItemsCriteria(), \PDO::PARAM_INT)
80  ),
81  $queryBuilder->expr()->eq(
82  'sys_category_record_mm.tablenames',
83  $queryBuilder->createNamedParameter('sys_file_metadata', \PDO::PARAM_STR)
84  )
85  )
86  ->execute();
87  $resourceFactory = ResourceFactory::getInstance();
88  while ($record = $statement->fetch()) {
89  $this->add($resourceFactory->getFileObject((int)$record['file']));
90  }
91  }
92 }
static makeInstance($className,...$constructorArguments)