protected function findOr404(Request $request, array $criteria = [])
    {
        // check whether request contains ID attribute
        if (!$request->attributes->has('id')) {
            throw new \LogicException('Request does not have "id" attribute set.');
        }

        $criteria['id'] = $request->attributes->get('id');

        if (null === $resource = $this->getManager()->getRepository()->findOneBy($criteria)) {
            throw new NotFoundHttpException(sprintf('Resource not found'));
        }

        return $resource;
    }
protected function findOr404(Request $request, array $criteria = [])
    {
        // check whether request contains ID attribute
        if (!$request->attributes->has('id')) {
            throw new \LogicException('Request does not have "id" attribute set.');
        }

        $criteria['id'] = $request->attributes->get('id');

        if (null === $resource = $this->getManager()->getRepository()->findOneBy($criteria)) {
            throw new NotFoundHttpException(sprintf('Resource not found'));
        }

        return $resource;
    }
protected function findOr404 ( Request $ request , array $ criteria = [ ] ) { // check whether request contains ID attribute if ( ! $ request -> attributes -> has ( 'id' ) ) { throw new \ LogicException ( 'Request does not have "id" attribute set.' ) ; } $ criteria [ 'id' ] = $ request -> attributes -> get ( 'id' ) ; if ( null === $ resource = $ this -> getManager ( ) -> getRepository ( ) -> findOneBy ( $ criteria ) ) { throw new NotFoundHttpException ( sprintf ( 'Resource not found' ) ) ; } return $ resource ; }
Returns resource by ID parameter

@param Request $request
@param array   $criteria

@return mixed
Returns resource by ID parameter