/** * @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; }
/** * @param Resource $resource * @param Module $module * @return Container */ public function loadModel(ModuleInterface $module, Context $context, PersisterObjectInterface $object = null) { // 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; }
/** * @param Resource $resource * @return Resource */ public function delete(PersisterObjectInterface $object) { $context = $this->contextLanguageMediator->getContextManager()->getContext(); $module = $object->getModule(); $container = $this->objectManager->getRepository("BigfishEavBundle:Container")->findOneByResource($object->getId(), $module->getId(), $context->getId()); // exit; $this->eavPersister->delete($container); $object->setDeleted(new \DateTime("now")); $this->objectManager->persist($object); $this->objectManager->flush(); return $object; }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('container_id', 'hidden', array('data' => $this->container->getId(), 'constraints' => array(new EqualTo(array('value' => $this->container->getId())))))->add('module_id', 'hidden', array('data' => $this->module->getId(), 'constraints' => array(new EqualTo(array('value' => $this->module->getId()))))); }