/** * Find an attribute by its id or return a 404 response * * @param int $id * * @throws NotFoundHttpException * * @return \Pim\Bundle\CatalogBundle\Model\AttributeInterface */ protected function findAttributeOr404($id) { $attribute = $this->attributeRepository->find($id); if (!$attribute) { throw new NotFoundHttpException(sprintf('Attribute with id %s could not be found.', $id)); } return $attribute; }
/** * Get an attribute or throw an exception * * @param int $id * * @throws EntityNotFoundException * * @return AttributeInterface * * @deprecated will be removed in 1.5 please use AttributeRepositoryInterface->find() */ public function getAttribute($id) { $attribute = $this->repository->find($id); if (null === $attribute) { throw new EntityNotFoundException(); } return $attribute; }