‪TYPO3CMS  9.5
CategoryBasedFileCollection.php
Go to the documentation of this file.
1 <?php
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 
50  public function ‪loadContents()
51  {
52  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_category');
53  $queryBuilder->getRestrictions()->removeAll();
54  $statement = $queryBuilder->select('sys_file_metadata.file')
55  ->from('sys_category')
56  ->join(
57  'sys_category',
58  'sys_category_record_mm',
59  'sys_category_record_mm',
60  $queryBuilder->expr()->eq(
61  'sys_category_record_mm.uid_local',
62  $queryBuilder->quoteIdentifier('sys_category.uid')
63  )
64  )
65  ->join(
66  'sys_category_record_mm',
67  'sys_file_metadata',
68  'sys_file_metadata',
69  $queryBuilder->expr()->eq(
70  'sys_category_record_mm.uid_foreign',
71  $queryBuilder->quoteIdentifier('sys_file_metadata.uid')
72  )
73  )
74  ->where(
75  $queryBuilder->expr()->eq(
76  'sys_category.uid',
77  $queryBuilder->createNamedParameter($this->getItemsCriteria(), \PDO::PARAM_INT)
78  ),
79  $queryBuilder->expr()->eq(
80  'sys_category_record_mm.tablenames',
81  $queryBuilder->createNamedParameter('sys_file_metadata', \PDO::PARAM_STR)
82  )
83  )
84  ->execute();
85  $resourceFactory = ‪ResourceFactory::getInstance();
86  while ($record = $statement->fetch()) {
87  $this->‪add($resourceFactory->getFileObject((int)$record['file']));
88  }
89  }
90 }
‪TYPO3\CMS\Core\Resource\Collection
Definition: AbstractFileCollection.php:2
‪TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection
Definition: AbstractFileCollection.php:24
‪TYPO3\CMS\Core\Resource\ResourceFactory\getInstance
‪static ResourceFactory getInstance()
Definition: ResourceFactory.php:39
‪TYPO3\CMS\Core\Resource\Collection\CategoryBasedFileCollection
Definition: CategoryBasedFileCollection.php:26
‪TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection\add
‪add(FileInterface $data)
Definition: AbstractFileCollection.php:188
‪TYPO3\CMS\Core\Resource\Collection\CategoryBasedFileCollection\$storageTableName
‪static string $storageTableName
Definition: CategoryBasedFileCollection.php:29
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:33
‪TYPO3\CMS\Core\Resource\Collection\CategoryBasedFileCollection\$type
‪static string $type
Definition: CategoryBasedFileCollection.php:33
‪TYPO3\CMS\Core\Resource\Collection\CategoryBasedFileCollection\$itemsCriteriaField
‪static string $itemsCriteriaField
Definition: CategoryBasedFileCollection.php:37
‪TYPO3\CMS\Core\Resource\Collection\CategoryBasedFileCollection\loadContents
‪loadContents()
Definition: CategoryBasedFileCollection.php:46
‪TYPO3\CMS\Core\Resource\Collection\CategoryBasedFileCollection\$itemTableName
‪string $itemTableName
Definition: CategoryBasedFileCollection.php:41
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45