public function operatorAuthor(Query $query, TokenInterface $token)
    {
        $value = explode(',', $token->value());

        if (!empty($value)) {
            $conjunction = $token->negated() ? 'NOT IN' : 'IN';
            $subQuery = TableRegistry::get('User.Users')->find()
                ->select(['id'])
                ->where(["Users.username {$conjunction}" => $value]);

            if ($token->where() === 'or') {
                $query->orWhere(['Contents.created_by IN' => $subQuery]);
            } elseif ($token->where() === 'and') {
                $query->andWhere(['Contents.created_by IN' => $subQuery]);
            } else {
                $query->where(['Contents.created_by IN' => $subQuery]);
            }
        }

        return $query;
    }
public function operatorAuthor(Query $query, TokenInterface $token)
    {
        $value = explode(',', $token->value());

        if (!empty($value)) {
            $conjunction = $token->negated() ? 'NOT IN' : 'IN';
            $subQuery = TableRegistry::get('User.Users')->find()
                ->select(['id'])
                ->where(["Users.username {$conjunction}" => $value]);

            if ($token->where() === 'or') {
                $query->orWhere(['Contents.created_by IN' => $subQuery]);
            } elseif ($token->where() === 'and') {
                $query->andWhere(['Contents.created_by IN' => $subQuery]);
            } else {
                $query->where(['Contents.created_by IN' => $subQuery]);
            }
        }

        return $query;
    }
public function operatorAuthor ( Query $ query , TokenInterface $ token ) { $ value = explode ( ',' , $ token -> value ( ) ) ; if ( ! empty ( $ value ) ) { $ conjunction = $ token -> negated ( ) ? 'NOT IN' : 'IN' ; $ subQuery = TableRegistry :: get ( 'User.Users' ) -> find ( ) -> select ( [ 'id' ] ) -> where ( [ "Users.username {$conjunction}" => $ value ] ) ; if ( $ token -> where ( ) === 'or' ) { $ query -> orWhere ( [ 'Contents.created_by IN' => $ subQuery ] ) ; } elseif ( $ token -> where ( ) === 'and' ) { $ query -> andWhere ( [ 'Contents.created_by IN' => $ subQuery ] ) ; } else { $ query -> where ( [ 'Contents.created_by IN' => $ subQuery ] ) ; } } return $ query ; }
Handles "author" search operator.

author:<username1>,<username2>, ...

@param \Cake\ORM\Query $query The query object
@param \Search\Parser\TokenInterface $token Operator token
@return \Cake\ORM\Query
Handles author search operator .