Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, PageInterface $page = NULL, $page_variant_id = NULL, $layout_region_id = NULL)
 {
     $this->page = $page;
     $this->pageVariant = $page->getVariant($page_variant_id);
     $this->pageVariant->init($this->page->getExecutable());
     $this->layoutRegion = $this->pageVariant->getLayoutRegion($layout_region_id);
     $form = parent::buildForm($form, $form_state);
     if ($this->getRequest()->isXmlHttpRequest()) {
         $form['actions']['submit']['#ajax'] = array('callback' => array($this, 'submitForm'));
     }
     return $form;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, PageInterface $page = NULL, $display_variant_id = NULL)
 {
     $this->page = $page;
     $this->displayVariant = $this->prepareDisplayVariant($display_variant_id);
     if ($this->displayVariant instanceof PageAwareVariantInterface) {
         $this->displayVariant->setExecutable($this->page->getExecutable());
     }
     // Allow the display variant to add to the form.
     $form['display_variant'] = $this->displayVariant->buildConfigurationForm([], $form_state);
     $form['display_variant']['#tree'] = TRUE;
     $form['actions'] = ['#type' => 'actions'];
     $form['actions']['submit'] = ['#type' => 'submit', '#value' => $this->submitText(), '#button_type' => 'primary'];
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, PageInterface $page = NULL, $page_variant_id = NULL)
 {
     // @todo: this is clearly not restful - but let's get this on the road
     switch ($request->getMethod()) {
         case 'PUT':
             $page_variant = $page->getVariant($page_variant_id);
             $page_variant->init($page->getExecutable());
             if (!$page_variant) {
                 throw BadRequestHttpException('Invalid page variant id provided');
             }
             $payload = $request->getContent();
             $data = json_decode($payload, TRUE);
             return $this->handlePut($page, $page_variant, $data);
             break;
         default:
             throw new BadRequestHttpException('Invalid HTTP method, currently only PUT supported');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, PageInterface $page = NULL, $page_variant_id = NULL, $layout_region_id = NULL, $block_id = NULL)
 {
     $this->page = $page;
     $this->displayVariant = $this->page->getVariant($page_variant_id);
     $this->displayVariant->setExecutable($page->getExecutable());
     $this->layoutRegion = $this->displayVariant->getLayoutRegion($layout_region_id);
     $this->block = $this->prepareBlock($block_id);
     $form['#tree'] = TRUE;
     $form['settings'] = $this->block->buildConfigurationForm(array(), $form_state);
     $form['settings']['id'] = array('#type' => 'value', '#value' => $this->block->getPluginId());
     // @note: we removed the region widget as it is implicit in URL.
     if ($this->block instanceof ContextAwarePluginInterface) {
         $form['context_assignments'] = $this->addContextAssignmentElement($this->block, $this->displayVariant->getContexts());
     }
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->submitText(), '#button_type' => 'primary');
     if ($this->getRequest()->isXmlHttpRequest()) {
         $form['actions']['submit']['#ajax'] = array('callback' => array($this, 'submitForm'));
     }
     return $form;
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, PageInterface $page = NULL, $page_variant_id = NULL, $layout_region_id = NULL, $plugin_id = NULL)
 {
     $this->page = $page;
     $this->pageVariant = $page->getVariant($page_variant_id);
     $this->pageVariant->init($page->getExecutable());
     // Check for adding a (sub-)region to an existent region.
     if ($plugin_id) {
         $this->layoutRegion = $this->prepareLayoutRegion($plugin_id, $layout_region_id);
         $this->layoutRegion->parentLayoutRegion = $this->pageVariant->getLayoutRegion($layout_region_id);
     } else {
         $this->layoutRegion = $this->prepareLayoutRegion($layout_region_id);
     }
     // Allow the page variant to add to the form.
     $form['plugin'] = $this->layoutRegion->buildConfigurationForm(array(), $form_state);
     $form['plugin']['#tree'] = TRUE;
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->submitText(), '#button_type' => 'primary');
     if ($this->getRequest()->isXmlHttpRequest()) {
         $form['actions']['submit']['#ajax'] = array('callback' => array($this, 'submitForm'));
     }
     return $form;
 }