public function execute(): Query
    {
        // query is not filterable, return it as is.
        if (! $this->filterable) {
            return $this->query;
        }

        if ($this->hasFullAccess()) {
            return $this->query;
        }

        $where = $this->getWhereClause();
        if (! empty($where)) {
            // apply all conditions using the OR operator
            $where = ['OR' => $where];
        }

        if (empty($where)) {
            $primaryKey = $this->table->getPrimaryKey();
            Assert::string($primaryKey);

            // if user has neither owner nor full capability on current action then filter out all records
            $where = [$this->table->aliasField($primaryKey) => null];
        }

        $this->query->where($where);

        return $this->query;
    }
public function execute(): Query
    {
        // query is not filterable, return it as is.
        if (! $this->filterable) {
            return $this->query;
        }

        if ($this->hasFullAccess()) {
            return $this->query;
        }

        $where = $this->getWhereClause();
        if (! empty($where)) {
            // apply all conditions using the OR operator
            $where = ['OR' => $where];
        }

        if (empty($where)) {
            $primaryKey = $this->table->getPrimaryKey();
            Assert::string($primaryKey);

            // if user has neither owner nor full capability on current action then filter out all records
            $where = [$this->table->aliasField($primaryKey) => null];
        }

        $this->query->where($where);

        return $this->query;
    }
public function execute ( ) : Query { // query is not filterable, return it as is. if ( ! $ this -> filterable ) { return $ this -> query ; } if ( $ this -> hasFullAccess ( ) ) { return $ this -> query ; } $ where = $ this -> getWhereClause ( ) ; if ( ! empty ( $ where ) ) { // apply all conditions using the OR operator $ where = [ 'OR' => $ where ] ; } if ( empty ( $ where ) ) { $ primaryKey = $ this -> table -> getPrimaryKey ( ) ; Assert :: string ( $ primaryKey ) ; // if user has neither owner nor full capability on current action then filter out all records $ where = [ $ this -> table -> aliasField ( $ primaryKey ) => null ] ; } $ this -> query -> where ( $ where ) ; return $ this -> query ; }
Executes Query filtering functionality.

Filter Query results by applying where clause conditions based on current user capabilities. If current user has
limited access, then the appropriate condition will be applied to the SQL where clause.

Limited access includes:
- Index or view records only assigned to him.
- Index or view records assigned to users who report to him (supervisor access).
- Index or view records related to a parent module which the user has one of the two conditions above applied.

@return \Cake\ORM\Query
Executes Query filtering functionality .