BlockContentAddLocalAction.php 924 Bytes
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction.
6 7
 */

8
namespace Drupal\block_content\Plugin\Menu\LocalAction;
9 10

use Drupal\Core\Menu\LocalActionDefault;
11
use Drupal\Core\Routing\RouteMatchInterface;
12 13 14 15

/**
 * Modifies the 'Add custom block' local action.
 */
16
class BlockContentAddLocalAction extends LocalActionDefault {
17 18 19 20

  /**
   * {@inheritdoc}
   */
21 22
  public function getOptions(RouteMatchInterface $route_match) {
    $options = parent::getOptions($route_match);
23
    // If the route specifies a theme, append it to the query string.
24 25
    if ($theme = $route_match->getParameter('theme')) {
      $options['query']['theme'] = $theme;
26
    }
27
    // Adds a destination on custom block listing.
28
    if ($route_match->getRouteName() == 'block_content.list') {
29
      $options['query']['destination'] = 'admin/structure/block/block-content';
30
    }
31 32 33 34
    return $options;
  }

}