/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->getVariantPlugin()->removeBlock($this->block->getConfiguration()['uuid']); $this->pageVariant->save(); drupal_set_message($this->t('The block %label has been removed.', ['%label' => $this->block->label()])); $form_state->setRedirectUrl($this->getCancelUrl()); }
/** * Build a block row for the layout table. * * @param BlockPluginInterface $block * The block to render a row for. * @param $weight_delta * The calculated weight delta. * @param string $target_entity_type * @param string $bundle_entity_type * @param string $target_bundle * * @return array */ protected function buildBlockRow(BlockPluginInterface $block, $weight_delta, $target_entity_type, $bundle_entity_type, $target_bundle) { $configuration = $block->getConfiguration(); $block_row = ['#attributes' => ['class' => ['draggable']]]; $block_row['label'] = ['#plain_text' => $block->label()]; $block_row['category'] = ['#plain_text' => $block->getPluginDefinition()['category']]; $block_row['weight'] = ['#type' => 'weight', '#default_value' => isset($configuration['weight']) ? $configuration['weight'] : 0, '#delta' => $weight_delta, '#title' => $this->t('Weight for @block block', ['@block' => $block->label()]), '#title_display' => 'invisible', '#attributes' => ['class' => ['block-weight']]]; $block_row['operations'] = ['#type' => 'operations', '#links' => ['edit' => ['title' => $this->t('Edit'), 'url' => Url::fromRoute("entity_layout.{$target_entity_type}.block.edit", ['block_id' => $configuration['uuid'], $bundle_entity_type => $target_bundle]), 'attributes' => ['class' => ['use-ajax'], 'data-dialog-type' => 'modal', 'data-dialog-options' => Json::encode(['width' => 700])]], 'remove' => ['title' => $this->t('Remove'), 'url' => Url::fromRoute("entity_layout.{$target_entity_type}.block.remove", ['block_id' => $configuration['uuid'], $bundle_entity_type => $target_bundle]), 'attributes' => ['class' => ['use-ajax'], 'data-dialog-type' => 'modal', 'data-dialog-options' => Json::encode(['width' => 700])]]]]; return $block_row; }