phprs\Request::find PHP Метод

find() публичный Метод

public find ( string $expr, $create = false ) : [found,
$expr string jsonpath 表达式
$create 是否找不到就创建
Результат [found,
    public function find($expr, $create = false)
    {
        $res = $this->data->get($expr, false, $create);
        if (count($res) === 0) {
            return array(null, false);
        } else {
            if (count($res) === 1) {
                return array(&$res[0], true);
            } else {
                return array(&$res, true);
            }
        }
    }

Usage Example

Пример #1
0
 /**
  * 获取API实现类的实例
  * @param Request $request
  * @return object
  */
 public function getImpl($request)
 {
     Verify::isTrue($request !== null);
     if ($this->impl === null) {
         $injected =& $this->injected;
         $injected = array();
         $this->impl = $this->factory->create($this->class, null, null, function ($src, &$succeeded) use($request, &$injected) {
             list($val, $found) = $request->find($src);
             $succeeded = $found;
             $injected[$src] = $val;
             return $val;
         });
         asort($injected);
     }
     return $this->impl;
 }