Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 9 |
| BlockContentAddLocalAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 9 |
| getOptions | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 9 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction. | |
| */ | |
| namespace Drupal\block_content\Plugin\Menu\LocalAction; | |
| use Drupal\Core\Menu\LocalActionDefault; | |
| use Drupal\Core\Routing\RouteMatchInterface; | |
| use Drupal\Core\Routing\UrlGeneratorTrait; | |
| /** | |
| * Modifies the 'Add custom block' local action. | |
| */ | |
| class BlockContentAddLocalAction extends LocalActionDefault { | |
| use UrlGeneratorTrait; | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getOptions(RouteMatchInterface $route_match) { | |
| $options = parent::getOptions($route_match); | |
| // If the route specifies a theme, append it to the query string. | |
| if ($theme = $route_match->getParameter('theme')) { | |
| $options['query']['theme'] = $theme; | |
| } | |
| // Adds a destination on custom block listing. | |
| if ($route_match->getRouteName() == 'entity.block_content.collection') { | |
| $options['query']['destination'] = $this->url('<current>'); | |
| } | |
| return $options; | |
| } | |
| } |