/**
  * Get FeGroups that are allowed to view a file/folder (checks full rootline)
  *
  * @param ResourceInterface $resource
  * @return string
  */
 public function getPermissions(ResourceInterface $resource)
 {
     $currentPermissionsCheck = $resource->getStorage()->getEvaluatePermissions();
     $resource->getStorage()->setEvaluatePermissions(false);
     $feGroups = array();
     // loop trough the root line of an folder and check the permissions of every folder
     foreach ($this->getFolderRootLine($resource->getParentFolder()) as $folder) {
         // fetch folder permissions record
         $folderRecord = $this->utilityService->getFolderRecord($folder);
         // if record found check permissions
         if ($folderRecord) {
             if ($feGroups === array()) {
                 $feGroups = GeneralUtility::trimExplode(',', $folderRecord['fe_groups'], true);
             }
             if ($folderRecord['fe_groups']) {
                 $feGroups = GeneralUtility::keepItemsInArray($feGroups, $folderRecord['fe_groups']);
             }
             break;
         }
     }
     if ($resource instanceof File && $resource->getProperty('fe_groups')) {
         $feGroups = GeneralUtility::keepItemsInArray($feGroups, $resource->getProperty('fe_groups'));
     }
     $resource->getStorage()->setEvaluatePermissions($currentPermissionsCheck);
     return implode(',', $feGroups);
 }
 /**
  * Update folder permissions records when a folder is renamed
  *
  * @param Folder $folder
  * @param string $newName
  */
 public function postFolderRename(Folder $folder, $newName)
 {
     $newFolder = $folder->getParentFolder()->getSubfolder($newName);
     $oldStorageUid = $folder->getStorage()->getUid();
     $newStorageUid = $newFolder->getStorage()->getUid();
     $this->utilityService->updateFolderRecord($oldStorageUid, $folder->getHashedIdentifier(), $folder->getIdentifier(), array('storage' => $newStorageUid, 'folder_hash' => $newFolder->getHashedIdentifier(), 'folder' => $newFolder->getIdentifier()));
     if (!empty($this->folderMapping[$folder->getCombinedIdentifier()])) {
         $newMapping = $this->getSubFolderIdentifiers($newFolder);
         foreach ($this->folderMapping[$folder->getCombinedIdentifier()] as $key => $folderInfo) {
             $this->utilityService->updateFolderRecord($oldStorageUid, $folderInfo[0], $folderInfo[1], array('storage' => $newStorageUid, 'folder_hash' => $newMapping[$key][0], 'folder' => $newMapping[$key][1]));
         }
     }
 }