Horde_Registry::callByPackage PHP Method

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.
    public function callByPackage($app, $call, array $args = array(), array $options = array())
    {
        /* Note: calling hasMethod() makes sure that we've cached
         * $app's services and included the API file, so we don't try
         * to do it again explicitly in this method. */
        if (!$this->hasMethod($call, $app)) {
            throw new Horde_Exception(sprintf('The method "%s" is not defined in the API for %s.', $call, $app));
        }
        /* Load the API now. */
        $methods = ($api_ob = $this->_loadApi($app)) ? $api_ob->methods() : array();
        /* Make sure that the function actually exists. */
        if (!in_array($call, $methods)) {
            throw new Horde_Exception('The function implementing ' . $call . ' is not defined in ' . $app . '\'s API.');
        }
        /* Switch application contexts now, if necessary, before
         * including any files which might do it for us. Return an
         * error immediately if pushApp() fails. */
        $pushed = $this->pushApp($app, array('check_perms' => !in_array($call, $api_ob->noPerms()) && empty($options['noperms']) && $this->currentProcessAuth()));
        try {
            $result = call_user_func_array(array($api_ob, $call), $args);
            if ($result instanceof PEAR_Error) {
                $result = new Horde_Exception_Wrapped($result);
            }
        } catch (Horde_Exception $e) {
            $result = $e;
        }
        /* If we changed application context in the course of this
         * call, undo that change now. */
        if ($pushed === true) {
            $this->popApp();
        }
        if ($result instanceof Horde_Exception) {
            throw $result;
        }
        return $result;
    }

Usage Example

コード例 #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;
 }
All Usage Examples Of Horde_Registry::callByPackage