src/Traits/FindMethodTrait.php
protected function _findRecord($id, Subject $subject)
    {
        $repository = $this->_table();

        list($finder, $options) = $this->_extractFinder();
        $query = $repository->find($finder, $options);
        $query->where([current($query->aliasField($repository->getPrimaryKey())) => $id]);

        $subject->set([
            'repository' => $repository,
            'query' => $query
        ]);

        $this->_trigger('beforeFind', $subject);
        $entity = $subject->query->first();

        if (!$entity) {
            $this->_notFound($id, $subject);
        }

        $subject->set(['entity' => $entity, 'success' => true]);
        $this->_trigger('afterFind', $subject);

        return $entity;
    }
protected function _findRecord($id, Subject $subject)
    {
        $repository = $this->_table();

        list($finder, $options) = $this->_extractFinder();
        $query = $repository->find($finder, $options);
        $query->where([current($query->aliasField($repository->getPrimaryKey())) => $id]);

        $subject->set([
            'repository' => $repository,
            'query' => $query
        ]);

        $this->_trigger('beforeFind', $subject);
        $entity = $subject->query->first();

        if (!$entity) {
            $this->_notFound($id, $subject);
        }

        $subject->set(['entity' => $entity, 'success' => true]);
        $this->_trigger('afterFind', $subject);

        return $entity;
    }
protected function _findRecord ( $ id , Subject $ subject ) { $ repository = $ this -> _table ( ) ; list ( $ finder , $ options ) = $ this -> _extractFinder ( ) ; $ query = $ repository -> find ( $ finder , $ options ) ; $ query -> where ( [ current ( $ query -> aliasField ( $ repository -> getPrimaryKey ( ) ) ) => $ id ] ) ; $ subject -> set ( [ 'repository' => $ repository , 'query' => $ query ] ) ; $ this -> _trigger ( 'beforeFind' , $ subject ) ; $ entity = $ subject -> query -> first ( ) ; if ( ! $ entity ) { $ this -> _notFound ( $ id , $ subject ) ; } $ subject -> set ( [ 'entity' => $ entity , 'success' => true ] ) ; $ this -> _trigger ( 'afterFind' , $ subject ) ; return $ entity ; }
Find a record from the ID

@param string $id Record id
@param \Crud\Event\Subject $subject Event subject
@return \Cake\ORM\Entity
@throws \Exception
Find a record from the ID