Beispiel #1
0
 /**
  * Converts a BlockPluginInterface to a minimal array (id, label, weight and region/region)
  *
  * @param BlockPluginInterface $block
  * @return array
  */
 public static function blockToArray(BlockPluginInterface $block)
 {
     $config = $block->getConfiguration();
     $settings = isset($config['settings']) ? $config['settings'] : array();
     $definition = $block->getPluginDefinition();
     if (isset($config['label']) && !empty($config['label'])) {
         $label = $config['label'];
     } else {
         $label = isset($definition['admin_label']) ? $definition['admin_label'] : $block->getPluginId();
     }
     return array('id' => $config['uuid'], 'label' => $label, 'weight' => isset($config['weight']) ? $config['weight'] : 0, 'region' => $config['region']);
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $settings = array('values' => &$form_state['values']['settings'], 'errors' => $form_state['errors']);
     // Call the plugin submit handler.
     $this->block->submitConfigurationForm($form, $settings);
     if (!empty($form_state['values']['context_assignments'])) {
         $this->submitContextAssignment($this->block, $form_state['values']['context_assignments']);
     }
     $this->displayVariant->updateBlock($this->block->getConfiguration()['uuid'], array('region' => $this->layoutRegion->id()));
     $this->page->save();
     if ($this->getRequest()->isXmlHttpRequest()) {
         $response = new AjaxResponse();
         $response->addCommand(new CloseDialogCommand());
         $response->addCommand(new LayoutBlockReload($this->block));
         $form_state['response'] = $response;
         return $response;
     }
     return new Url('page_manager.display_variant_edit', array('page' => $this->page->id(), 'display_variant_id' => $this->displayVariant->id()));
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $this->displayVariant->removeBlock($this->block->getConfiguration()['uuid']);
     $this->page->save();
     drupal_set_message($this->t('The block %name has been removed.', array('%name' => $this->block->getConfiguration()['label'])));
     if ($this->getRequest()->isXmlHttpRequest()) {
         $response = new AjaxResponse();
         $response->addCommand(new CloseDialogCommand());
         $response->addCommand(new LayoutBlockDelete($this->block));
         $form_state['response'] = $response;
         return $response;
     }
     $form_state['redirect_route'] = $this->getCancelRoute();
 }