TYPO3 CMS  TYPO3_6-2
FolderBasedFileCollection.php
Go to the documentation of this file.
1 <?php
3 
23 
27  static protected $storageTableName = 'sys_file_collection';
28 
32  static protected $type = 'folder';
33 
37  static protected $itemsCriteriaField = 'folder';
38 
44  protected $folder;
45 
58  public function loadContents() {
59  if ($this->folder instanceof \TYPO3\CMS\Core\Resource\Folder) {
60  $entries = $this->folder->getFiles();
61  foreach ($entries as $entry) {
62  $this->add($entry);
63  }
64  }
65  }
66 
72  public function getItemsCriteria() {
73  return $this->folder->getCombinedIdentifier();
74  }
75 
82  protected function getPersistableDataArray() {
83  return array(
84  'title' => $this->getTitle(),
85  'type' => self::$type,
86  'description' => $this->getDescription(),
87  'folder' => $this->folder->getIdentifier(),
88  'storage' => $this->folder->getStorage()->getUid()
89  );
90  }
91 
99  public function fromArray(array $array) {
100  $this->uid = $array['uid'];
101  $this->title = $array['title'];
102  $this->description = $array['description'];
103  if (!empty($array['folder']) && !empty($array['storage'])) {
105  $storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
107  $storage = $storageRepository->findByUid($array['storage']);
108  if ($storage) {
109  $this->folder = $storage->getFolder($array['folder']);
110  }
111  }
112  }
113 
114 }
add(\TYPO3\CMS\Core\Resource\FileInterface $data)