‪TYPO3CMS  9.5
FolderBasedFileCollection.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 = 'folder';
36 
40  protected static ‪$itemsCriteriaField = 'folder';
41 
47  protected ‪$folder;
48 
52  protected ‪$recursive;
53 
64  public function ‪loadContents()
65  {
66  if ($this->folder instanceof ‪Folder) {
67  $entries = $this->folder->getFiles(0, 0, ‪Folder::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, $this->recursive);
68  foreach ($entries as $entry) {
69  $this->‪add($entry);
70  }
71  }
72  }
73 
79  public function ‪getItemsCriteria()
80  {
81  return $this->folder->getCombinedIdentifier();
82  }
83 
90  protected function ‪getPersistableDataArray()
91  {
92  return [
93  'title' => $this->‪getTitle(),
94  'type' => ‪self::$type,
95  'description' => $this->‪getDescription(),
96  'folder' => $this->folder->getIdentifier(),
97  'storage' => $this->folder->getStorage()->getUid()
98  ];
99  }
100 
108  public function ‪fromArray(array $array)
109  {
110  $this->uid = $array['uid'];
111  $this->title = $array['title'];
112  $this->description = $array['description'];
113  $this->recursive = (bool)$array['recursive'];
114  if (!empty($array['folder']) && !empty($array['storage'])) {
116  $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
118  ‪$storage = $storageRepository->findByUid($array['storage']);
119  if (‪$storage) {
120  $this->folder = ‪$storage->getFolder($array['folder']);
121  }
122  }
123  }
124 }
‪TYPO3\CMS\Core\Resource\Collection
Definition: AbstractFileCollection.php:2
‪TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection
Definition: AbstractFileCollection.php:24
‪TYPO3\CMS\Core\Collection\AbstractRecordCollection\$storage
‪SplDoublyLinkedList $storage
Definition: AbstractRecordCollection.php:74
‪TYPO3\CMS\Core\Collection\AbstractRecordCollection\getTitle
‪string getTitle()
Definition: AbstractRecordCollection.php:189
‪TYPO3\CMS\Core\Resource\Folder\FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
‪const FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
Definition: Folder.php:66
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\$folder
‪TYPO3 CMS Core Resource Folder $folder
Definition: FolderBasedFileCollection.php:43
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\fromArray
‪fromArray(array $array)
Definition: FolderBasedFileCollection.php:103
‪TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection\add
‪add(FileInterface $data)
Definition: AbstractFileCollection.php:188
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:34
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection
Definition: FolderBasedFileCollection.php:26
‪TYPO3\CMS\Core\Resource\StorageRepository
Definition: StorageRepository.php:29
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\getPersistableDataArray
‪array getPersistableDataArray()
Definition: FolderBasedFileCollection.php:85
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\getItemsCriteria
‪string getItemsCriteria()
Definition: FolderBasedFileCollection.php:74
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\$recursive
‪bool $recursive
Definition: FolderBasedFileCollection.php:47
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\$itemsCriteriaField
‪static string $itemsCriteriaField
Definition: FolderBasedFileCollection.php:37
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\loadContents
‪loadContents()
Definition: FolderBasedFileCollection.php:59
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Collection\AbstractRecordCollection\getDescription
‪string getDescription()
Definition: AbstractRecordCollection.php:209
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\$type
‪static string $type
Definition: FolderBasedFileCollection.php:33
‪TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection\$storageTableName
‪static string $storageTableName
Definition: FolderBasedFileCollection.php:29