Beispiel #1
0
 /**
  * @param PersisterObjectInterface $object
  * @param ModuleInterface          $module
  *
  * @return Container|mixed
  */
 public function loadModel(ModuleInterface $module, Context $context, PersisterObjectInterface $object = null)
 {
     $container = null;
     if ($object) {
         // find container
         $container = $this->objectManager->getRepository('BigfishEavBundle:Container')->findOneBy(array('id' => $object->getId(), 'module' => $module->getId(), 'context' => $context->getId()));
     }
     // if container is not found, create one
     if (!$container) {
         $container = new Container();
         $container->setDeleted(new \DateTime());
         $container->setExpireTemporaryDate(new \DateTime('+ 3 hour'));
         $container->setModule($module);
         $container->setContext($context);
         $this->objectManager->persist($container);
         return $container;
     }
     return $container;
 }
Beispiel #2
0
 /**
  * @param Resource $resource
  * @param Module $module
  * @return Container
  */
 public function loadModel(ModuleInterface $module, PersisterObjectInterface $object = null)
 {
     $context = $this->contextLanguageMediator->getContextManager()->getContext();
     // find container
     $container = $this->objectManager->getRepository("BigfishEavBundle:Container")->findOneByResource($object->getId(), $module->getId(), $context->getId());
     // if container is not found, create one
     if (!$container) {
         $container = new Container();
         $container->setContext($context);
         $container->setResource($object);
         $container->setModule($module);
         $this->objectManager->persist($container);
         return $container;
     }
     return $container;
 }