/** * Retrieves tag with id $id or throws an exception if it doesn't exist. * * @param int $id A Tag identifier * * @return TagInterface * * @throws NotFoundHttpException */ protected function getTag($id) { $tag = $this->tagManager->find($id); if (null === $tag) { throw new NotFoundHttpException(sprintf('Tag (%d) not found', $id)); } return $tag; }
/** * @param TagInterface|int $id * @param TagInterface $default * * @return TagInterface */ protected final function getTag($id, TagInterface $default = null) { if ($id instanceof TagInterface) { return $id; } if (is_numeric($id)) { return $this->tagManager->find($id); } return $default; }