container = $_container; $this->entityManager = $_container->get('doctrine.orm.entity_manager'); $this->agridCacheService = $_container->get('agrid.cache_service'); $this->repository = $this->entityManager->getRepository(AGridModuleNewsFeed::class); } /** * @param AGridModuleNewsFeed $element * @return AGridModuleNewsFeed|null */ public function update(AGridModuleNewsFeed $element) { return $this->quickUpdate($element); } /** * @param AGridModuleNewsFeed $element * @return AGridModuleNewsFeed|null */ public function quickUpdate(AGridModuleNewsFeed $element) { if (!$this->entityManager->contains($element)) { try { $this->entityManager->persist($element); } catch (ORMException $e) { return null; } } try { $this->entityManager->flush(); } catch (OptimisticLockException $e) { return null; } catch (ORMException $e) { return null; } return $element; } /** * @param AGridModuleNewsFeed $element * @return boolean */ public function delete(AGridModuleNewsFeed $element) { try { $this->entityManager->remove($element); } catch (ORMException $e) { return false; } try { $this->entityManager->flush(); } catch (OptimisticLockException $e) { return false; } catch (ORMException $e) { return false; } return true; } public function getAllByModuleAndFeed(AGridModule $module, AGridNewsFeed $feed){ return $this->repository->findBy(['module'=>$module, 'newsFeed'=>$feed]); } }