Horde_Kolab_Storage_Cache::loadAttachment PHP Method

loadAttachment() public method

Retrieve an attachment.
public loadAttachment ( string $data_id, string $obid, string $attachment_id ) : resource
$data_id string ID of the data set.
$obid string Object backend id.
$attachment_id string Attachment ID.
return resource A stream opened to the attachment data.
    public function loadAttachment($data_id, $obid, $attachment_id)
    {
        $data = $this->_horde_cache->get($this->_getAttachmentId($data_id, $obid, $attachment_id), 0);
        return $data === false ? $data : Horde_Stream_Wrapper_String::getStream($data);
    }

Usage Example

Beispiel #1
0
 /**
  * Retrieves an attachment by name.
  *
  * @param string $obid           Object backend id.
  * @param string $attachment_id  Attachment ID.
  *
  * @return array  An array of attachment resources.
  */
 public function getAttachmentByType($obid, $type)
 {
     $object = $this->getObjectByBackendId($obid);
     if (!isset($object['_attachments']['type'][$type])) {
         throw new Horde_Kolab_Storage_Exception(sprintf('No attachment with type "%s" for object id %s!', $type, $obid));
     }
     $result = array();
     foreach ($object['_attachments']['type'][$type] as $attachment_id) {
         $result[$attachment_id] = $this->_cache->loadAttachment($this->getDataId(), $obid, $attachment_id);
     }
     return $result;
 }