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