entityManager = $_container->get('doctrine.orm.entity_manager'); $this->class = $_class; } /** * @param FormForgeFieldValueInterface $element * @return bool */ public function quickUpdateValue(FormForgeFieldValueInterface $element){ if(empty($element)) return false; try { $this->entityManager->persist($element); $this->entityManager->flush(); } catch (ORMException $e) { return false; } return true; } /** * @param FormForgeFieldValueInterface $element * @return bool */ public function deleteValue(FormForgeFieldValueInterface $element){ if($this->entityManager->contains($element)){ try { $this->entityManager->remove($element); $this->entityManager->flush(); } catch (ORMException $e) { return false; } } return true; } /** * @param string $publicKey * @return FormForgeFieldValueInterface|null */ public function getCustomFieldValueByPublicKey(string $publicKey): ?FormForgeFieldValueInterface { $field = $this->entityManager->getRepository($this->class)->findOneBy(['publicKey'=>$publicKey]); if (empty($field)) return null; return $field; } public function getById($id){ // return $this->entityManager->getRepository($this->class)->getFormForgeValueById($id); return $this->entityManager->getRepository($this->class)->find($id); } }