/**
  * Set up
  *
  * @return void
  */
 public function setUp()
 {
     $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
     $this->fileCollectionMock = $this->getAccessibleMock('\\TYPO3\\CMS\\Core\\Resource\\Collection\\AbstractFileCollection', array('loadContents', 'getItems'), array(), '', FALSE);
     $this->fileCollectionMock->expects($this->atLeastOnce())->method('loadContents');
     $this->fileCollectionRepositoryMock = $this->getMock('\\TYPO3\\CMS\\Core\\Resource\\FileCollectionRepository', array('findByUid'), array(), '', FALSE);
     $this->fileCollectionRepositoryMock->expects($this->any())->method('findByUid')->will($this->returnValue($this->fileCollectionMock));
     $this->frontendConfigurationManagerMock = $this->getMock('\\TYPO3\\CMS\\Extbase\\Configuration\\FrontendConfigurationManager', array('getConfiguration'), array(), '', FALSE);
     $this->storageMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
     $this->storageMock->expects($this->any())->method('getUid')->will($this->returnValue(5));
     $this->subject = GeneralUtility::makeInstance('SKYFILLERS\\SfFilecollectionGallery\\Service\\FileCollectionService');
     $this->subject->injectFileCollectionRepository($this->fileCollectionRepositoryMock);
     $this->subject->injectFrontendConfigurationManager($this->frontendConfigurationManagerMock);
 }
 /**
  * Returns an array of file objects for the given UIDs of fileCollections
  *
  * @param array $collectionUids The uids
  *
  * @return array
  */
 public function getFileObjectsFromCollection(array $collectionUids)
 {
     $imageItems = array();
     foreach ($collectionUids as $collectionUid) {
         $collection = $this->fileCollectionRepository->findByUid($collectionUid);
         $collection->loadContents();
         foreach ($collection->getItems() as $item) {
             if (get_class($item) === 'TYPO3\\CMS\\Core\\Resource\\FileReference') {
                 array_push($imageItems, $this->getFileObjectFromFileReference($item));
             } else {
                 array_push($imageItems, $item);
             }
         }
     }
     return $this->sortFileObjects($imageItems);
 }
 /**
  * load all collections from database
  * 
  * @return true
  */
 protected function loadCollectionsFromDb()
 {
     // check if there are any collections
     if (count($this->collectionIds) > 0) {
         // Get all existing collections
         foreach ($this->collectionIds as $uid) {
             $this->collections[] = $this->fileCollectionRepository->findByUid($uid);
         }
         // Load the records in each file collection
         foreach ($this->collections as $c) {
             $c->loadContents();
             // load and set description of file collection which is not loaded by default
             $c->setDescription($this->getSysFileCollectionData($c->getIdentifier()));
         }
     }
 }