src/Controller/Component/DataTablesComponent.php
public function find($tableName, $finder = 'all', array $options = [])
    {

        // -- get table object
        $table = TableRegistry::get($tableName);
        $this->_tableName = $table->alias();

        // -- get query options
        $this->_processRequest();
        $data = $table->find($finder, $options);

        // -- record count
        $this->_viewVars['recordsTotal'] = $data->count();

        // -- filter result
        $data->where($this->config('conditionsAnd'));
        foreach($this->config('matching') as $association => $where) {
            $data->matching( $association, function ($q) use ($where) {
                return $q->where($where);
            });
        };
        $data->andWhere(['or' => $this->config('conditionsOr')]);

        $this->_viewVars['recordsFiltered'] = $data->count();

        // -- add limit
        $data->limit( $this->config('length') );
        $data->offset( $this->config('start') );

        // -- sort
        $data->order( $this->config('order') );

        // -- set all view vars to view and serialize array
        $this->_setViewVars();
        return $data;

    }
public function find($tableName, $finder = 'all', array $options = [])
    {

        // -- get table object
        $table = TableRegistry::get($tableName);
        $this->_tableName = $table->alias();

        // -- get query options
        $this->_processRequest();
        $data = $table->find($finder, $options);

        // -- record count
        $this->_viewVars['recordsTotal'] = $data->count();

        // -- filter result
        $data->where($this->config('conditionsAnd'));
        foreach($this->config('matching') as $association => $where) {
            $data->matching( $association, function ($q) use ($where) {
                return $q->where($where);
            });
        };
        $data->andWhere(['or' => $this->config('conditionsOr')]);

        $this->_viewVars['recordsFiltered'] = $data->count();

        // -- add limit
        $data->limit( $this->config('length') );
        $data->offset( $this->config('start') );

        // -- sort
        $data->order( $this->config('order') );

        // -- set all view vars to view and serialize array
        $this->_setViewVars();
        return $data;

    }
Find data

@param $tableName
@param $finder
@param array $options
@return array|\Cake\ORM\Query