‪TYPO3CMS  ‪main
FolderBasedFileCollection.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 = 'folder';
37 
41  protected static ‪$itemsCriteriaField = 'folder';
42 
48  protected ‪$folder;
49 
53  protected ‪$recursive;
54 
65  public function ‪loadContents()
66  {
67  if ($this->folder instanceof ‪Folder) {
68  $entries = $this->folder->getFiles(0, 0, ‪Folder::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, $this->recursive);
69  foreach ($entries as $entry) {
70  $this->‪add($entry);
71  }
72  }
73  }
74 
80  public function ‪getItemsCriteria()
81  {
82  return $this->folder->getCombinedIdentifier();
83  }
84 
91  protected function ‪getPersistableDataArray()
92  {
93  return [
94  'title' => $this->‪getTitle(),
95  'type' => ‪self::$type,
96  'description' => $this->‪getDescription(),
97  'folder_identifier' => $this->folder->getCombinedIdentifier(),
98  ];
99  }
100 
106  public function ‪fromArray(array $array)
107  {
108  $this->uid = $array['uid'];
109  $this->title = $array['title'];
110  $this->‪description = $array['description'];
111  $this->recursive = (bool)$array['recursive'];
112  if (str_contains($array['folder_identifier'] ?? '', ':')) {
113  $parts = ‪GeneralUtility::trimExplode(':', $array['folder_identifier']);
114  $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
115  ‪$storage = $storageRepository->findByUid((int)$parts[0]);
116  if (‪$storage) {
117  $this->folder = ‪$storage->getFolder($parts[1]);
118  }
119  }
120  }
121 }
‪TYPO3\CMS\Core\Resource\Collection
Definition: AbstractFileCollection.php:16
‪TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection
Definition: AbstractFileCollection.php:28
‪TYPO3\CMS\Core\Collection\AbstractRecordCollection\$storage
‪SplDoublyLinkedList $storage
Definition: AbstractRecordCollection.php:81
‪TYPO3\CMS\Core\Collection\AbstractRecordCollection\getTitle
‪string getTitle()
Definition: AbstractRecordCollection.php:171
‪TYPO3\CMS\Core\Resource\Folder\FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
‪const FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
Definition: Folder.php:70
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\$folder
‪TYPO3 CMS Core Resource Folder $folder
Definition: FolderBasedFileCollection.php:44
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\fromArray
‪fromArray(array $array)
Definition: FolderBasedFileCollection.php:101
‪TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection\add
‪add(FileInterface $data)
Definition: AbstractFileCollection.php:188
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:38
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection
Definition: FolderBasedFileCollection.php:27
‪TYPO3\CMS\Core\Resource\StorageRepository
Definition: StorageRepository.php:38
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\getPersistableDataArray
‪array getPersistableDataArray()
Definition: FolderBasedFileCollection.php:86
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\getItemsCriteria
‪string getItemsCriteria()
Definition: FolderBasedFileCollection.php:75
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\$recursive
‪bool $recursive
Definition: FolderBasedFileCollection.php:48
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\$itemsCriteriaField
‪static string $itemsCriteriaField
Definition: FolderBasedFileCollection.php:38
‪TYPO3\CMS\Redirects\Message\description
‪identifier description
Definition: RedirectWasHitMessage.php:32
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\loadContents
‪loadContents()
Definition: FolderBasedFileCollection.php:60
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Collection\AbstractRecordCollection\getDescription
‪string getDescription()
Definition: AbstractRecordCollection.php:191
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\$type
‪static string $type
Definition: FolderBasedFileCollection.php:34
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode(string $delim, string $string, bool $removeEmptyValues=false, int $limit=0)
Definition: GeneralUtility.php:822
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\$storageTableName
‪static string $storageTableName
Definition: FolderBasedFileCollection.php:30