BlockContentAddLocalAction.php 1.21 KB
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 Symfony\Cmf\Component\Routing\RouteObjectInterface;
12 13 14 15 16
use Symfony\Component\HttpFoundation\Request;

/**
 * Modifies the 'Add custom block' local action.
 */
17
class BlockContentAddLocalAction extends LocalActionDefault {
18 19 20 21 22 23 24 25 26 27

  /**
   * {@inheritdoc}
   */
  public function getOptions(Request $request) {
    $options = parent::getOptions($request);
    // If the route specifies a theme, append it to the query string.
    if ($request->attributes->has('theme')) {
      $options['query']['theme'] = $request->attributes->get('theme');
    }
28
    // Adds a destination on custom block listing.
29 30
    if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'block_content.list') {
      $options['query']['destination'] = 'admin/structure/block/block-content';
31
    }
32
    // Adds a destination on custom block listing.
33 34
    if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'block_content.list') {
      $options['query']['destination'] = 'admin/structure/block/block-content';
35
    }
36 37 38 39
    return $options;
  }

}