/** * @param Form $form * @throws Exceptions\MissingTagException * @return Entities\TagEntity|null */ protected function getSelectedTag(Form $form) { $tagId = $form->getHttpData(Form::DATA_LINE, 'tagId'); $tag = $tagId ? $this->tagRepository->getById($tagId) : null; if (!$tag) { throw new Exceptions\MissingTagException($this->translator->translate('locale.error.missing_tag')); } return $tag; }