entityManager = $_container->get('doctrine.orm.entity_manager'); $this->fieldTemplateRepository = $this->entityManager->getRepository(FormForgeTemplate::class); } /** * @param FormForgeTemplate $element * @return bool */ public function quickUpdate(FormForgeTemplate $element){ if(empty($element)) return false; try { $this->entityManager->persist($element); $this->entityManager->flush(); } catch (ORMException $e) { return false; } return true; } /** * @param int $id * @return FormForgeTemplate|object|null */ public function getById(int $id){ return $this->fieldTemplateRepository->find($id); } public function create(string $_fieldType,string $_twigName, string $_content) { $template = new FormForgeTemplate(); $template->setDefault($_fieldType, $_twigName, $_content); if (!$this->quickUpdate($template)) return null; return $template; } public function edit() { } }