class BlockContentAddLocalAction
Same name in other branches
- 9 core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction
- 8.9.x core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction
- 11.x core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction
Modifies the 'Add content block' local action.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Menu\LocalActionDefault extends \Drupal\Component\Plugin\PluginBase implements \Drupal\Core\Menu\LocalActionInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\Core\Cache\CacheableDependencyInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction extends \Drupal\Core\Menu\LocalActionDefault
- class \Drupal\Core\Menu\LocalActionDefault extends \Drupal\Component\Plugin\PluginBase implements \Drupal\Core\Menu\LocalActionInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\Core\Cache\CacheableDependencyInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait
Expanded class hierarchy of BlockContentAddLocalAction
1 string reference to 'BlockContentAddLocalAction'
- block_content.links.action.yml in core/
modules/ block_content/ block_content.links.action.yml - core/modules/block_content/block_content.links.action.yml
File
-
core/
modules/ block_content/ src/ Plugin/ Menu/ LocalAction/ BlockContentAddLocalAction.php, line 15
Namespace
Drupal\block_content\Plugin\Menu\LocalActionView source
class BlockContentAddLocalAction extends LocalActionDefault {
/**
* Constructs a BlockContentAddLocalAction object.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteProviderInterface $routeProvider, RequestStack $requestStack) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $routeProvider);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container->get('router.route_provider'), $container->get('request_stack'));
}
/**
* {@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;
}
// 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;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.