/** * @return Form */ public function createForm() { $entityClass = $this->options->getEntityClass(); $builder = new AnnotationBuilder($this->getEntityManager()); /** * @var $form Form */ $form = $builder->createForm(new $entityClass()); $form->setHydrator(new DoctrineObject($this->getEntityManager())); foreach ($form->getElements() as $element) { if ($element instanceof \DoctrineModule\Form\Element\ObjectSelect || $element instanceof \DoctrineModule\Form\Element\ObjectRadio || $element instanceof \DoctrineModule\Form\Element\ObjectMultiCheckbox) { $element->setOption('object_manager', $this->getEntityManager()); } elseif ($element instanceof \MfccAdminModule\Form\Element\CyclicSheet) { $form->addTab($element->getName(), ['label' => $element->getLabel(), 'action' => 'cyclicSheetAction', 'entity' => $element->getOption('target_class'), 'active' => false]); $form->remove($element->getName()); } } return $form; }
/** * @param $id * @return object */ public function findById($id) { $er = $this->em->getRepository($this->options->getEntityClass()); return $er->findOneBy(['id' => $id, 'deleted' => 0]); }