Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / block_content / src / Plugin / Menu / LocalAction / BlockContentAddLocalAction.php
1 <?php
2
3 namespace Drupal\block_content\Plugin\Menu\LocalAction;
4
5 use Drupal\Core\Menu\LocalActionDefault;
6 use Drupal\Core\Routing\RouteMatchInterface;
7 use Drupal\Core\Routing\UrlGeneratorTrait;
8
9 /**
10  * Modifies the 'Add custom block' local action.
11  */
12 class BlockContentAddLocalAction extends LocalActionDefault {
13   use UrlGeneratorTrait;
14
15   /**
16    * {@inheritdoc}
17    */
18   public function getOptions(RouteMatchInterface $route_match) {
19     $options = parent::getOptions($route_match);
20     // If the route specifies a theme, append it to the query string.
21     if ($theme = $route_match->getParameter('theme')) {
22       $options['query']['theme'] = $theme;
23     }
24     // Adds a destination on custom block listing.
25     if ($route_match->getRouteName() == 'entity.block_content.collection') {
26       $options['query']['destination'] = $this->url('<current>');
27     }
28     return $options;
29   }
30
31 }