当前位置: 首页>>代码示例>>PHP>>正文


PHP Filters::run方法代码示例

本文整理汇总了PHP中Filters::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Filters::run方法的具体用法?PHP Filters::run怎么用?PHP Filters::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Filters的用法示例。


在下文中一共展示了Filters::run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: instance

 /**
  * Uses service location (i.e. `Libraries::locate()`) to look up a named class of a particular
  * type, and creates an instance of it, and passes an array of parameters to the constructor.
  *
  * If the given class can't be found, an exception is thrown.
  *
  * @param string $type The type of class as defined by `Libraries::$_paths`.
  * @param string $name The un-namespaced name of the class to instantiate.
  * @param array $options An array of constructor parameters to pass to the class.
  * @return object If the class is found, returns an instance of it, otherwise throws an
  *         exception.
  * @throws lithium\core\ClassNotFoundException Throws an exception if the class can't be found.
  * @filter
  */
 public static function instance($type, $name, array $options = array())
 {
     $params = compact('type', 'name', 'options');
     $_paths =& static::$_paths;
     $implementation = function ($self, $params) use(&$_paths) {
         $name = $params['name'];
         $type = $params['type'];
         if (!$name && !$type) {
             $message = "Invalid class lookup: `\$name` and `\$type` are empty.";
             throw new ClassNotFoundException($message);
         }
         if (!is_string($type) && $type !== null && !isset($_paths[$type])) {
             throw new ClassNotFoundException("Invalid class type `{$type}`.");
         }
         if (!($class = $self::locate($type, $name))) {
             throw new ClassNotFoundException("Class `{$name}` of type `{$type}` not found.");
         }
         if (is_object($class)) {
             return $class;
         }
         if (!(is_string($class) && class_exists($class))) {
             throw new ClassNotFoundException("Class `{$name}` of type `{$type}` not defined.");
         }
         return new $class($params['options']);
     };
     if (!isset(static::$_methodFilters[__FUNCTION__])) {
         return $implementation(get_called_class(), $params);
     }
     $class = get_called_class();
     $method = __FUNCTION__;
     $data = array_merge(static::$_methodFilters[__FUNCTION__], array($implementation));
     return Filters::run($class, $params, compact('data', 'class', 'method'));
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:47,代码来源:Libraries.php

示例2: _filter

 /**
  * Executes a set of filters against a method by taking a method's main implementation as a
  * callback, and iteratively wrapping the filters around it. This, along with the `Filters`
  * class, is the core of Lithium's filters system. This system allows you to "reach into" an
  * object's methods which are marked as _filterable_, and intercept calls to those methods,
  * optionally modifying parameters or return values.
  *
  * @see lithium\core\Object::applyFilter()
  * @see lithium\util\collection\Filters
  *
  * @param string  $method   The name of the method being executed, usually the value of
  *                          `__METHOD__`.
  * @param array   $params   An associative array containing all the parameters passed into
  *                          the method.
  * @param Closure $callback The method's implementation, wrapped in a closure.
  * @param array   $filters  Additional filters to apply to the method for this call only.
  *
  * @return mixed Returns the return value of `$callback`, modified by any filters passed in
  *         `$filters` or applied with `applyFilter()`.
  */
 protected function _filter($method, $params, $callback, $filters = array())
 {
     list($class, $method) = explode('::', $method);
     if (empty($this->_methodFilters[$method]) && empty($filters)) {
         return $callback($this, $params, null);
     }
     $f = isset($this->_methodFilters[$method]) ? $this->_methodFilters[$method] : array();
     $data = array_merge($f, $filters, array($callback));
     return Filters::run($this, $params, compact('data', 'class', 'method'));
 }
开发者ID:kaibosh,项目名称:nZEDb,代码行数:30,代码来源:Object.php


注:本文中的Filters::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。