callByPackage() public method

Output the hook corresponding to the specific package named.
public callByPackage ( string $app, string $call, array $args = [], array $options = [] ) : mixed
$app string The application being called.
$call string The method to call.
$args array Arguments to the method.
$options array Additional options: - noperms: (boolean) If true, don't check the perms.
return mixed Return from application call.
コード例 #1
0
ファイル: File.php プロジェクト: raz0rsdge/horde
 /**
  * Returns the data
  *
  * This method may either return a string or a readable stream resource
  *
  * @return mixed
  */
 public function get()
 {
     list($base) = explode('/', $this->_path);
     try {
         $items = $this->_registry->callByPackage($base, 'browse', array($this->_path));
     } catch (Horde_Exception_NotFound $e) {
         throw new DAV\Exception\NotFound($this->_path . ' not found');
     } catch (Horde_Exception $e) {
         throw new DAV\Exception($e);
     }
     if (!$items) {
         throw new DAV\Exception\NotFound($this->_path . ' not found');
     }
     $item = reset($items);
     $this->_size = strlen($item);
     return $item;
 }
コード例 #2
0
ファイル: Horde.php プロジェクト: raz0rsdge/horde
 /**
  * Returns an unsorted file list of the specified directory.
  *
  * @param string $path          The path of the directory.
  * @param string|array $filter  Regular expression(s) to filter
  *                              file/directory name on.
  * @param boolean $dotfiles     Show dotfiles?
  * @param boolean $dironly      Show only directories?
  *
  * @return array  File list.
  * @throws Horde_Vfs_Exception
  */
 protected function _listFolder($path, $filter = null, $dotfiles = true, $dironly = false)
 {
     $list = array();
     if ($path == '/') {
         try {
             $apps = $this->_registry->listApps(null, false, Horde_Perms::READ);
         } catch (Horde_Exception $e) {
             throw new Horde_Vfs_Exception($e->getMessage());
         }
         foreach ($apps as $app) {
             if ($this->_registry->hasMethod('browse', $app)) {
                 $file = array('name' => $app, 'date' => time(), 'type' => '**dir', 'size' => -1);
                 $list[] = $file;
             }
         }
         return $list;
     }
     if (substr($path, 0, 1) == '/') {
         $path = substr($path, 1);
     }
     $pieces = explode('/', $path);
     try {
         $items = $this->_registry->callByPackage($pieces[0], 'browse', array('path' => $path, 'properties' => array('name', 'browseable', 'contenttype', 'contentlength', 'modified')));
     } catch (Horde_Exception $e) {
         throw new Horde_Vfs_Exception($e->getMessage());
     }
     if (!is_array(reset($items))) {
         /* We return an object's content. */
         throw new Horde_Vfs_Exception('Unknown error');
     }
     foreach ($items as $sub_path => $i) {
         if ($dironly && !$i['browseable']) {
             continue;
         }
         $name = basename($sub_path);
         if ($this->_filterMatch($filter, $name)) {
             continue;
         }
         $type = class_exists('Horde_Mime_Magic') ? Horde_Mime_Magic::mimeToExt(empty($i['contenttype']) ? 'application/octet-stream' : $i['contenttype']) : '**none';
         $file = array('name' => $name, 'date' => empty($i['modified']) ? 0 : $i['modified'], 'type' => $i['browseable'] ? '**dir' : $type, 'size' => empty($i['contentlength']) ? 0 : $i['contentlength']);
         $list[] = $file;
     }
     return $list;
 }
コード例 #3
0
ファイル: Collection.php プロジェクト: jubinpatel/horde
 /**
  * Creates a new file in the directory
  *
  * @param string $name Name of the file
  * @param resource|string $data Initial payload
  * @return null|string
  */
 public function createFile($name, $data = null)
 {
     list($app) = explode('/', $this->_path);
     if (is_resource($data)) {
         $content = new Horde_Stream_Existing(array('stream' => $data));
         $type = Horde_Mime_Magic::analyzeData($content->getString(0, 100), $this->_mimedb);
     } else {
         $content = $data;
         $type = Horde_Mime_Magic::analyzeData($content, $this->_mimedb);
     }
     if (!$type) {
         $type = Horde_Mime_Magic::filenameToMime($name);
     }
     try {
         $this->_registry->callByPackage($app, 'put', array($this->_path . '/' . $name, $content, $type));
     } catch (Horde_Exception $e) {
         throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
     }
 }