/** * @param \Symfony\Component\Form\FormBuilderInterface $builder * * @return $this */ protected function addTitleField(FormBuilderInterface $builder) { $builder->add(self::FIELD_TITLE, 'text', ['label' => 'Title', 'constraints' => [new NotBlank(), new Callback(['methods' => [function ($name, ExecutionContextInterface $contextInterface) { if ($this->queryContainer->queryGroupByName($name)->count() > 0) { $contextInterface->addViolation('Group name already in use'); } }], 'groups' => [self::GROUP_UNIQUE_GROUP_CHECK]])]]); return $this; }
/** * @param string $name * * @return \Generated\Shared\Transfer\GroupTransfer */ public function getByName($name) { $groupEntity = $this->queryContainer->queryGroupByName($name)->findOne(); $groupTransfer = new GroupTransfer(); $groupTransfer->fromArray($groupEntity->toArray(), true); return $groupTransfer; }