public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('resourceHasInstance_id', 'hidden', array("data" => $this->resourceHasInstance->getId(), "constraints" => array(new EqualTo(array("value" => $this->resourceHasInstance->getId())))));
 }
 /**
  * @param Request $request
  * @param ResourceHasInstance $resourceHasInstance
  * @param Resource $resource
  * @return RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function duplicateAction(Request $request, ResourceHasInstance $resourceHasInstance, Resource $resource)
 {
     $culture = $this->languageManager->getCulture();
     /** @var \Bigfish\Bundle\EavBundle\Entity\Module $module */
     $module = $resourceHasInstance->getInstance()->getComponent()->getModule();
     // Add a custom form type for the component itself.
     $formBuilder = $this->createFormBuilder()->add('instance', new InstanceType($resourceHasInstance));
     /** @var \Bigfish\Bundle\EavBundle\Form\FormBuilder $form */
     $form = $this->get('eav.form.builder')->createFormBuilder($module, array('container' => $resourceHasInstance->getInstance()->getContainer()), array(), $formBuilder)->getForm();
     if ($this->formHandler->handleDuplicate($form, $request, $resourceHasInstance, $resource)) {
         return new JsonResponse(array("success" => true));
     }
     return $this->render('BigfishPagekitBundle:Component:edit.html.twig', array('form' => $form->createView(), 'actionUrl' => $this->generateUrl('pagekit_component_duplicate', array('resourceHasInstance' => $resourceHasInstance->getId(), 'resource' => $resource->getId(), 'bflanguage' => $culture))));
 }
Exemple #3
0
 /**
  * @param ModuleInterface $module
  * @param Context $context
  * @param EavPersisterObjectInterface $object
  * @param Component $component
  * @return Instance
  */
 public function createTemporary(ModuleInterface $module, Context $context, EavPersisterObjectInterface $object = null, Component $component, Area $area, Resource $resource)
 {
     $container = $this->eavPersister->loadModel($module, $context, $object);
     // Create a temporary instance based on the container we just created.
     $instance = new Instance();
     $instance->setContainer($container);
     $instance->setComponent($component);
     $instance->setDeleted(new \DateTime());
     $instance->setExpireTemporaryDate(new \DateTime("+3 hour"));
     $this->objectManager->persist($instance);
     // Link the instance to the area and resource.
     $resourceHasInstance = new ResourceHasInstance();
     $resourceHasInstance->setResource($resource);
     $resourceHasInstance->setArea($area);
     $resourceHasInstance->setInstance($instance);
     $this->objectManager->persist($resourceHasInstance);
     $this->objectManager->flush();
     return $resourceHasInstance;
 }
 /**
  * @param FormInterface $form
  * @param Request $request
  * @param Resource $resource
  * @return bool
  */
 public function handleUpdate(FormInterface $form, Request $request, ResourceHasInstance $resourceHasInstance)
 {
     $form->setData($this->eavPersister->find($resourceHasInstance->getInstance()->getContainer()));
     if ($this->handle($form, $request)) {
         $this->pagekitPersister->update($resourceHasInstance, $form->getData());
         return true;
     }
     return false;
 }