entityManager = $_container->get('doctrine.orm.entity_manager'); $this->repository = $this->entityManager->getRepository(AGridModuleType::class); $this->agridCacheService = $_container->get('agrid.cache_service'); } /** * @param AGridModuleType $element * @return bool */ public function quickUpdate(AGridModuleType $element): bool { try { if (!$this->entityManager->contains($element)) { if ($element) $this->entityManager->persist($element); else return false; } $this->entityManager->flush(); } catch (OptimisticLockException $e) { return false; } catch (ORMException $e) { return false; } return true; } /** * @param AGridModuleType $element * @return bool */ public function update(AGridModuleType $element): bool { return $this->quickUpdate($element); } public function getAllModuleType(){ return $this->repository->findAll(); } public function getByTypeUniqId(string $typeUniqId) { return $this->repository->findOneBy(['typeUniqId'=>$typeUniqId]); } /** * @param AGridModule $module * @return AGridModuleTypeContent[]|null */ public function getTypeContent(AGridModule $module){ $type = $module->getTypeId(); if($type !== null) return $this->entityManager->getRepository(AGridModuleTypeContent::class)->findBy(['moduleType'=>$type]); return null; } }