use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Theme\ThemeManagerInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
*/
protected $limit = FALSE;
+ /**
+ * The messenger.
+ *
+ * @var \Drupal\Core\Messenger\MessengerInterface
+ */
+ protected $messenger;
+
/**
* Constructs a new BlockListBuilder object.
*
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder.
*/
- public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, ThemeManagerInterface $theme_manager, FormBuilderInterface $form_builder) {
+ public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, ThemeManagerInterface $theme_manager, FormBuilderInterface $form_builder, MessengerInterface $messenger) {
parent::__construct($entity_type, $storage);
$this->themeManager = $theme_manager;
$this->formBuilder = $form_builder;
+ $this->messenger = $messenger;
}
/**
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('theme.manager'),
- $container->get('form_builder')
+ $container->get('form_builder'),
+ $container->get('messenger')
);
}
'#theme_wrappers' => [
'container' => [
'#attributes' => ['class' => 'region-title__action'],
- ]
+ ],
],
'#prefix' => $title,
'#type' => 'link',
if (isset($operations['delete'])) {
$operations['delete']['title'] = $this->t('Remove');
+ // Block operation links should have the `block-placement` query string
+ // parameter removed to ensure that JavaScript does not receive a block
+ // name that has been recently removed.
+ foreach ($operations as $operation) {
+ /** @var \Drupal\Core\Url $url */
+ $url = $operation['url'];
+ $query = $url->getOption('query');
+ $destination = $query['destination'];
+
+ $destinationUrl = Url::fromUserInput($destination);
+ $destinationQuery = $destinationUrl->getOption('query');
+ unset($destinationQuery['block-placement']);
+
+ $destinationUrl->setOption('query', $destinationQuery);
+ $query['destination'] = $destinationUrl->toString();
+ $url->setOption('query', $query);
+ }
}
return $operations;
}
$entity->setRegion($entity_values['region']);
$entity->save();
}
- drupal_set_message(t('The block settings have been updated.'));
+ $this->messenger->addStatus($this->t('The block settings have been updated.'));
// Remove any previously set block placement.
$this->request->query->remove('block-placement');