/** * @param Request $request * @return object|null */ private function getObject(Request $request) { $id = $request->get('id'); if (empty($id)) { return null; } $object = $this->element->getDataIndexer()->getData($id); if (!$object) { throw new NotFoundHttpException(sprintf('Can\'t find object with id %s', $id)); } return $object; }