权限检验.

@param Passport $passport
@param string   $op
@param array    $extra

@return bool
196534
public final function check(Passport $passport, $op, $extra) {
        $rst = $this->doCheck($passport, $op, $extra);
        if ($rst && $this->next) {
            $rst = $this->next->check($passport, $op, $extra);
        }

        return $rst;
    }
1103614
public function getCount( $collection, $column, $value, $excludeId = null, $idColumn = null, array $extra = [] )
	{
		$query = $this->table( $collection )->where( $column, '=', $value );

		if ( !is_null( $excludeId ) && $excludeId != 'NULL' )
		{
			$query->where( $idColumn ?: 'id', '<>', $excludeId );
		}

		foreach ( $extra as $key => $extraValue )
		{
			$this->addWhere( $query, $key, $extraValue );
		}

		return $query->count();
	}
780358
public void prepareParameter(Map<String, Object> extra) {
        if (from != null)
        {
            from.prepareParameter(extra);
        }
    }
1056727
public function getCount($collection, $column, $value, $excludeId = null, $idColumn = null, array $extra = [])
    {
        $builder = $this->em->createQueryBuilder();

        $builder->select('count(e)')->from($collection, 'e');
        $builder->where("e.{$column} = :{$column}");

        if (!is_null($excludeId) && $excludeId != 'NULL') {
            $idColumn = $idColumn ?: 'id';
            $builder->andWhere("e.{$idColumn} <> :{$idColumn}");
        }

        foreach ($extra as $key => $extraValue) {
            $builder->andWhere("e.{$key} = :{$key}");
        }

        $query = $builder->getQuery();
        $query->setParameter($column, $value);

        if (!is_null($excludeId) && $excludeId != 'NULL') {
            $query->setParameter($idColumn, $excludeId);
        }

        foreach ($extra as $key => $extraValue) {
            $query->setParameter($key, $extraValue);
        }

        return $query->getSingleScalarResult();
    }
982393
public function showAction($id, $extra) {
        $entity = $this->container->get("template_page.read_handler")->get($id);

        $template = str_replace(":show.html.twig", ":display.html.twig", $this->container->get("request")->get('_template'));

        $params = array(
            "entity" => $entity
            , "extra" => $extra
        );

        return new Response($this->container->get('templating')->render($template, $params));
    }
945546
function doOperation(operation) {
        if (operation.ops.length > 0) {
            try {
                $(exports).triggerHandler('beforeExecuteOperation', [operation]);
                _applyOperation(operation);
                if (operation.bypass !== true) {
                    _undoStack.push(operation);
                    _redoStack.clear();
                    $(exports).triggerHandler('operationExecuted', [operation]);
                }
            } catch (err) {
                console.error(err);
            }
        }
    }
714535
public function callHook($name, &$params, $extra = null)
    {
        $results = [];
        $hooks = $this->getHook($name);

        // 排序
        usort($hooks, [
            $this,
            'compareHookWeight'
        ]);

        foreach ($hooks as $key => $hook) {
            $results[$key] = $this->executeHook($hook['behavior'], $params, $extra);

            // 返回false则停止执行
            if (false === $results[$key]) {
                break;
            }
        }
        return $results;
    }
960807
protected function convertMap(Op\MapOp $op)
    {
        $mapOp   = new ProtoBuf\MapOp();
        $updates = [];
        $removes = [];

        foreach ($op->getMapUpdates() as $key => $value) {
            $map    = $this->convertMap($value);
            $update = $this->createMapUpdate($key, MapFieldType::MAP, $map);

            $updates[] = $update;
        }

        foreach ($op->getSetUpdates() as $key => $value) {
            $set    = $this->convertSet($value);
            $update = $this->createMapUpdate($key, MapFieldType::SET, $set);

            $updates[] = $update;
        }

        foreach ($op->getFlagUpdates() as $key => $value) {
            $flag   = $this->convertFlag($value);
            $update = $this->createMapUpdate($key, MapFieldType::FLAG, $flag);

            $updates[] = $update;
        }

        foreach ($op->getCounterUpdates() as $key => $value) {
            $counter = $this->convertCounter($value);
            $update  = $this->createMapUpdate($key, MapFieldType::COUNTER, $counter);

            $updates[] = $update;
        }

        foreach ($op->getRegisterUpdates() as $key => $value) {
            $register = $value->getValue();
            $update   = $this->createMapUpdate($key, MapFieldType::REGISTER, $register);

            $updates[] = $update;
        }

        foreach ($op->getMapRemoves() as $key => $value) {
            $removes[] = $this->createMapField($key, MapFieldType::MAP);
        }

        foreach ($op->getSetRemoves() as $key => $value) {
            $removes[] = $this->createMapField($key, MapFieldType::SET);
        }

        foreach ($op->getFlagRemoves() as $key => $value) {
            $removes[] = $this->createMapField($key, MapFieldType::FLAG);
        }

        foreach ($op->getCounterRemoves() as $key => $value) {
            $removes[] = $this->createMapField($key, MapFieldType::COUNTER);
        }

        foreach ($op->getRegisterRemoves() as $key => $value) {
            $removes[] = $this->createMapField($key, MapFieldType::REGISTER);
        }

        $mapOp->setUpdates($updates);
        $mapOp->setRemoves($removes);

        return $mapOp;
    }
351614
protected function parseStatusResults($result, array $extra_result_data = array())
    {
        $result = trim($result);

        $this->checkForUnrecoverableError($result);

        return $this->checkForStatusResult($result);
    }
96500
protected function runOperation($op, $method = 'post', array $body = [])
    {
        if (!$this->operationAvailable($op, true)) {
            throw new OperationUnavailableException("Operation not available: $op");
        }
        $options = [];
        if (!empty($body)) {
            $options['json'] = $body;
        }
        $request= new Request($method, $this->getLink("#$op"));
        $data = $this->send($request, $this->client, $options);

        return new Result($data, $this->baseUrl, $this->client, get_called_class());
    }
213866
function initialize(passport) {
  const middleware = promisify(_initialize(passport))
  return function passportInitialize(ctx, next) {
    // koa <-> connect compatibility:
    const userProperty = passport._userProperty || 'user'
    // check ctx.req has the userProperty
    if (!ctx.req.hasOwnProperty(userProperty)) {
      Object.defineProperty(ctx.req, userProperty, {
        enumerable: true,
        get: function() {
          return ctx.state[userProperty]
        },
        set: function(val) {
          ctx.state[userProperty] = val
        }
      })
    }

    // create mock object for express' req object
    const req = createReqMock(ctx, userProperty)


    // add Promise-based login method
    const login  = req.login
    ctx.login = ctx.logIn = function(user, options) {
      return new Promise((resolve, reject) => {
        login.call(req, user, options, err => {
          if (err) reject(err)
          else resolve()
        })
      })
    }

    // add aliases for passport's request extensions to Koa's context
    ctx.logout = ctx.logOut = req.logout.bind(req)
    ctx.isAuthenticated     = req.isAuthenticated.bind(req)
    ctx.isUnauthenticated   = req.isUnauthenticated.bind(req)

    return middleware(req, ctx).then(function() {
      return next()
    })
  }
}
311849
protected function importCustomizeExtra( $rootParagraphId, $extra )
    {
        /* @var $mapper \Grid\Customize\Model\Extra\Mapper */
        $model  = $this->getSheetModel();
        $mapper = $model->getMapper()->getExtraMapper();
        $extra  = $mapper->create( array(
            'rootParagraphId'   => $rootParagraphId,
            'extra'             => $extra,
        ) );

        return $extra->save();
    }
549764
public function retrieveResponse(OAuthUriInterface $endpoint, $requestBody, array $extraHeaders = [], $method = 'POST')
    {
        $request = new Request();
        $request
            ->setUri($endpoint->getAbsoluteUri())
            ->setMethod($method)
            ->getHeaders()->addHeaders($extraHeaders);
        if (is_array($requestBody)) {
            $request->getPost()->fromArray($requestBody);
        } else {
            $request->setContent($requestBody);
        }
        $response = $this->client->send($request);

        return $response->getBody();
    }
1127898
public function saveHistory($extra = null)
    {
        if (!is_null($extra)) {
            self::$queries[] = $extra;
            self::$params[] = null;
        }

        self::$queries[] = 'Saved query-history to session.';
        self::$params[] = null;

        $key = $this->options['session_key'];
        $_SESSION[$key]['numQueries'] = self::$numQueries;
        $_SESSION[$key]['queries']    = self::$queries;
        $_SESSION[$key]['params']     = self::$params;
    }
479293
private function _where($method, $key, $op = '', $val = '')
    {
        $where = ['where' => '', 'whereIn' => 'in', 'whereNotIn' => 'not in', 'whereNull' => 'is', 'whereNotNull' => 'is not', 'whereExists' => 'exists', 'whereNotExists' => 'not exists', 'whereBetween' => 'between', 'whereNotBetween' => 'not between', 'orWhere' => '', 'orWhereIn' => 'in', 'orWhereNotIn' => 'not in', 'orWhereNull' => 'is', 'orWhereNotNull' => 'is not', 'orWhereExists' => 'exists', 'orWhereNotExists' => 'not exists', 'orWhereBetween' => 'between', 'orWhereNotBetween' => 'not between'];

        if (!isset($where[$method])) {
            throw new \Error('找不到您要执行的方法' . $method);
        }
        //兼容 where 直接传递一个关联数组的情况
        if (($method == 'where' || $method == 'orWhere') && is_array($key)) {
            foreach ($key as $k => $v) {
                $this->_where($method, $k, '=', $v);
            }
            return $this;
        }
        if (strpos($method, 'xists') === false) {
            $key = $this->formatColumn($key);
        }
        //非这俩方法时不需要指定操作符
        if ($method != 'where' && $method != 'orWhere') {
            $val = $op;
        }
        //设定操作符和连接符
        $type = strpos($method, 'or') !== false ? ' or ' : ' and ';
        $_op = $where[$method];
        $op = $_op ? $_op : $op;
        if ($op == 'is' || $op == 'is not') {
            $val = 'null';
        }
        $val = is_array($val) ? $val : (string)$val;

        $this->_sql['where'][] = [$key, $op, $val, $type];
        return $this;
    }
235582
public function addExtra($extra)
    {
        $functions = $extra->getFunctions();
        if ($functions && is_array($functions)) {
            foreach ($functions as $function) {
                $this->twig->addFunction($function);
            }
        }
        $filters = $extra->getFilters();
        if ($filters && is_array($filters)) {
            foreach ($filters as $filter) {
                $this->twig->addFilter($filter);
            }
        }
        $globals = $extra->getGlobals();
        if ($globals && is_array($globals)) {
            foreach ($globals as $key => $value) {
                $this->twig->addGlobal($key, $value);
            }
        }
    }
1252915
public function where($query, $queryParams = null, string $op = ''): self
    {
        if ($query == '') {
            throw new BuilderException('Query required!');
        }

        // sub-where
        if ($queryParams instanceof Builder) {
            // $opr argument is empty, should be exists in query (eg: id = )
            $query = $this->prepare($query, '', $queryParams);

            return $this->push('where', $query);
        }

        if (is_array($query)) {
            // eg: [['id' => ...], ...]
            foreach ($query as $field => $params) {
                // eg: ['id' => [1, '=', '?', 'or/and']], ['a.id' => [id('b.id'), ...]]
                if (is_array($params)) {
                    @ [$params, $operator, $escapeOperator, $op] = (array) $params;
                    if ($operator == null) {
                        $operator = '='; // @default=equal
                    }
                    $query = '?? '. $operator .' '. ($params instanceof Identifier ? '??' : $escapeOperator ?: '?');
                    $queryParams = [$field, $params];
                } else {
                    // eg: ['id' => 1]
                    $query = '?? = '. ($params instanceof Identifier ? '??' : '?');
                    $queryParams = [$field, $params];
                }

                $op = $op ? strtoupper($op) : self::OP_AND;
                if ($op != self::OP_OR && $op != self::OP_AND) {
                    throw new BuilderException('Available ops: OR, AND');
                }

                $query = $this->agent->prepare($query, $queryParams);

                $this->push('where', [[$query, $op]]);
            }

            return $this;
        }

        if (!is_string($query)) {
            throw new BuilderException(sprintf('String, array or Builder type queries are accepted only, %s given!',
                gettype($query)));
        }

        if ($queryParams !== null) {
            if (!is_array($queryParams) && !is_scalar($queryParams) && !($queryParams instanceof Identifier)) {
                throw new BuilderException(sprintf('Array, scalar and Query\Identifier params are accepted only, %s given!',
                    gettype($queryParams)));
            }
        }

        $query = $this->agent->prepare($query, $queryParams);

        $op = $op ? strtoupper($op) : self::OP_AND;
        if ($op != self::OP_OR && $op != self::OP_AND) {
            throw new BuilderException('Available ops: OR, AND');
        }

        return $this->push('where', [[$query, $op]]);
    }