Ejemplo n.º 1
0
 public function createTemporary(TemplateInterface $template, Resource $parent = null, EavPersisterObjectInterface $object = null)
 {
     $context = $this->contextLanguageMediator->getContextManager()->getContext();
     $culture = $this->contextLanguageMediator->getLanguageManager()->getObject();
     $module = $template->getModule();
     /** @var EavPersisterObjectInterface $container */
     $container = $this->eavPersister->loadModel($module, $context, $object);
     $resource = new Resource();
     $resource->setExpireTemporaryDate(new \DateTime("+3 hour"));
     $resource->setContext($context);
     $resource->setTemplate($template);
     if ($parent) {
         $resource->setParent($parent);
     }
     $this->objectManager->persist($resource);
     $translation = new ResourceTranslation();
     $translation->setResource($resource);
     $translation->setLanguage($culture);
     $translation->setName(uniqid());
     $this->objectManager->persist($translation);
     $container->setResource($resource);
     $this->objectManager->persist($container);
     $this->objectManager->flush();
     return $resource;
 }