Horde_Kolab_Storage_List_Cache::getFolders PHP Method

getFolders() public method

Returns the list of folders from the cache.
public getFolders ( ) : array
return array The list of folders, represented as a list of strings.
    public function getFolders()
    {
        $this->_load();
        if (isset($this->_data[self::FOLDERS])) {
            return $this->_data[self::FOLDERS];
        } else {
            throw new Horde_Kolab_Storage_Exception(sprintf('Missing cache data (Key: %s). Synchronize first!', self::FOLDERS));
        }
    }

Usage Example

Example #1
0
 /**
  * Set the specified folder as default for its current type.
  *
  * @param array  $folder   The folder data.
  * @param string|boolean $previous The previous default folder or false if there was none.
  */
 public function setDefault($folder, $previous = false)
 {
     if (!$this->_cache->hasNamespace()) {
         // Cache not synchronized yet.
         return;
     }
     if ($folder['namespace'] !== Horde_Kolab_Storage_Folder_Namespace::PERSONAL) {
         throw new Horde_Kolab_Storage_List_Exception(sprintf("Unable to mark %s as a default folder. It is not within your personal namespace!", $folder['folder']));
     }
     $annotations = $this->_cache->getFolderTypes();
     if (!isset($annotations[$folder['folder']])) {
         throw new Horde_Kolab_Storage_List_Exception(sprintf("The folder %s has no Kolab type. It cannot be marked as 'default' folder!", $folder['folder']));
     }
     if ($previous) {
         $this->_driver->setAnnotation($previous, Horde_Kolab_Storage_List_Query_List::ANNOTATION_FOLDER_TYPE, $folder['type']);
         $annotations[$previous] = $folder['type'];
     }
     $this->_driver->setAnnotation($folder['folder'], Horde_Kolab_Storage_List_Query_List::ANNOTATION_FOLDER_TYPE, $folder['type'] . '.default');
     $annotations[$folder['folder']] = $folder['type'] . '.default';
     $folder_list = $this->_cache->getFolders();
     $namespace = unserialize($this->_cache->getNamespace());
     $this->_synchronize($namespace, $folder_list, $annotations);
 }