public function getParentRegionOptions() { $regions = $this->pageVariant->getLayoutRegions(); $options = array(); $contained_region_ids = $this->getAllContainedRegionIds(); foreach ($regions as $region) { // @todo: filter to avoid nesting bugs & filter for valid parent region types. if ($region->id() !== $this->id() && !in_array($region->id(), $contained_region_ids)) { $options[$region->id()] = $region->label(); } } return $options; }
/** * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->pageVariant->removeLayoutRegion($this->layoutRegion->id()); $this->page->save(); drupal_set_message($this->t('The layout region %name has been removed.', array('%name' => $this->layoutRegion->label()))); if ($this->getRequest()->isXmlHttpRequest()) { $response = new AjaxResponse(); $response->addCommand(new CloseDialogCommand()); $response->addCommand(new LayoutReload($this->pageVariant)); $form_state['response'] = $response; return $response; } $form_state['redirect_route'] = $this->getCancelRoute(); }
public function handlePut(PageInterface $page, LayoutPageVariantInterface $page_variant, $data = array()) { foreach ($data['regions'] as $region) { foreach ($region['blocks'] as $block_data) { $block = $page_variant->getBlock($block_data['id']); if ($block) { $configuration = $block->getConfiguration(); $configuration['region'] = $region['id']; $configuration['weight'] = $block_data['weight']; $block->setConfiguration($configuration); } } } $page->save(); return new Response('{}', 200, array('Content-Type' => 'application/json')); }
/** * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { // Allow the page variant to submit the form. $plugin_values = array('values' => &$form_state['values']['plugin']); $this->layoutRegion->submitConfigurationForm($form, $plugin_values); $this->pageVariant->updateLayoutRegion($this->layoutRegion->id(), array('label' => $this->layoutRegion->label(), 'parent' => $this->layoutRegion->getParentRegionId())); $this->page->save(); if ($this->getRequest()->isXmlHttpRequest()) { $response = new AjaxResponse(); $response->addCommand(new CloseDialogCommand()); if ($this->getFormId() === 'layout_layout_region_add_form') { $response->addCommand(new LayoutReload($this->pageVariant)); } else { $response->addCommand(new LayoutRegionReload($this->pageVariant, $this->layoutRegion)); } $form_state['response'] = $response; return $response; } $form_state['redirect_route'] = new Url('page_manager.display_variant_edit', array('page' => $this->page->id(), 'display_variant_id' => $this->pageVariant->id())); }
public static function getLayoutPageVariantClientData(LayoutPageVariantInterface $page_variant) { $page = $page_variant->getPage(); return array('layout' => array('id' => $page->id(), 'pageId' => $page->id(), 'variantId' => $page_variant->id(), 'layoutData' => self::getGroupedBlockArrays($page_variant), 'locked' => FALSE, 'webserviceURL' => \Drupal::urlGenerator()->generateFromRoute('layout.page_variant_layout_rest', array('page' => $page->id(), 'page_variant_id' => $page_variant->id())))); }