Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BlockContentAddLocalAction.php

function BlockContentAddLocalAction::getOptions

Overrides LocalActionDefault::getOptions

File

core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php, line 46

Class

BlockContentAddLocalAction
Modifies the 'Add content 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;
    }
    // If the current request has a region, append it to the query string.
    if ($region = $this->requestStack
        ->getCurrentRequest()->query
        ->getString('region')) {
        $options['query']['region'] = $region;
    }
    // Adds a destination on content block listing.
    if ($route_match->getRouteName() == 'entity.block_content.collection') {
        $options['query']['destination'] = Url::fromRoute('<current>')->toString();
    }
    return $options;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal