You are here

public function BlockContentAddLocalAction::getOptions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction::getOptions()

Returns options for rendering a link for the local action.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.

Return value

array An associative array of options.

Overrides LocalActionDefault::getOptions

File

core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php, line 23
Contains \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction.

Class

BlockContentAddLocalAction
Modifies the 'Add custom block' local action.

Namespace

Drupal\block_content\Plugin\Menu\LocalAction

Code

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;
}