Horde_Registry::callAppMethod PHP Method

callAppMethod() public method

Call a private Horde application method.
public callAppMethod ( string $app, string $call, array $options = [] ) : mixed
$app string The application name.
$call string The method to call.
$options array Additional options: - args: (array) Additional parameters to pass to the method. - check_missing: (boolean) If true, throws an Exception if method does not exist. Otherwise, will return null. - noperms: (boolean) If true, don't check the perms.
return mixed Various.
    public function callAppMethod($app, $call, array $options = array())
    {
        /* Load the API now. */
        try {
            $api = $this->getApiInstance($app, 'application');
        } catch (Horde_Exception $e) {
            if (empty($options['check_missing'])) {
                return null;
            }
            throw $e;
        }
        if (!method_exists($api, $call)) {
            if (empty($options['check_missing'])) {
                return null;
            }
            throw new Horde_Exception('Method does not exist.');
        }
        /* 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' => empty($options['noperms']) && $this->currentProcessAuth()));
        try {
            $result = call_user_func_array(array($api, $call), empty($options['args']) ? array() : $options['args']);
        } 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 Exception) {
            throw $e;
        }
        return $result;
    }

Usage Example

コード例 #1
0
ファイル: Backend.php プロジェクト: kossamums/horde
 /**
  * Deletes a card
  *
  * @param mixed $addressBookId
  * @param string $cardUri
  * @return bool
  */
 public function deleteCard($addressBookId, $cardUri)
 {
     try {
         return $this->_registry->callAppMethod($this->_contacts(), 'davDeleteObject', array('args' => array($addressBookId, $cardUri)));
     } catch (Horde_Exception $e) {
         throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
     }
 }
All Usage Examples Of Horde_Registry::callAppMethod