class WorkspaceSwitcherBlock
Same name in other branches
- 9 core/modules/workspaces/src/Plugin/Block/WorkspaceSwitcherBlock.php \Drupal\workspaces\Plugin\Block\WorkspaceSwitcherBlock
- 10 core/modules/workspaces/src/Plugin/Block/WorkspaceSwitcherBlock.php \Drupal\workspaces\Plugin\Block\WorkspaceSwitcherBlock
- 11.x core/modules/workspaces/src/Plugin/Block/WorkspaceSwitcherBlock.php \Drupal\workspaces\Plugin\Block\WorkspaceSwitcherBlock
Provides a 'Workspace switcher' block.
Plugin annotation
@Block(
id = "workspace_switcher",
admin_label = @Translation("Workspace switcher"),
category = @Translation("Workspace"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Component\Plugin\ContextAwarePluginBase extends \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\ContextAwarePluginInterface
- class \Drupal\Core\Plugin\ContextAwarePluginBase extends \Drupal\Component\Plugin\ContextAwarePluginBase implements \Drupal\Core\Plugin\ContextAwarePluginInterface, \Drupal\Core\Cache\CacheableDependencyInterface uses \Drupal\Core\TypedData\TypedDataTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Core\Block\BlockBase extends \Drupal\Core\Plugin\ContextAwarePluginBase implements \Drupal\Core\Block\BlockPluginInterface, \Drupal\Core\Plugin\PluginWithFormsInterface, \Drupal\Core\Render\PreviewFallbackInterface uses \Drupal\Core\Block\BlockPluginTrait, \Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait
- class \Drupal\workspaces\Plugin\Block\WorkspaceSwitcherBlock extends \Drupal\Core\Block\BlockBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface
- class \Drupal\Core\Block\BlockBase extends \Drupal\Core\Plugin\ContextAwarePluginBase implements \Drupal\Core\Block\BlockPluginInterface, \Drupal\Core\Plugin\PluginWithFormsInterface, \Drupal\Core\Render\PreviewFallbackInterface uses \Drupal\Core\Block\BlockPluginTrait, \Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait
- class \Drupal\Core\Plugin\ContextAwarePluginBase extends \Drupal\Component\Plugin\ContextAwarePluginBase implements \Drupal\Core\Plugin\ContextAwarePluginInterface, \Drupal\Core\Cache\CacheableDependencyInterface uses \Drupal\Core\TypedData\TypedDataTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Component\Plugin\ContextAwarePluginBase extends \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\ContextAwarePluginInterface
Expanded class hierarchy of WorkspaceSwitcherBlock
File
-
core/
modules/ workspaces/ src/ Plugin/ Block/ WorkspaceSwitcherBlock.php, line 21
Namespace
Drupal\workspaces\Plugin\BlockView source
class WorkspaceSwitcherBlock extends BlockBase implements ContainerFactoryPluginInterface {
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilderInterface
*/
protected $formBuilder;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new WorkspaceSwitcherBlock instance.
*
* @param array $configuration
* The plugin configuration.
* @param string $plugin_id
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $form_builder, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->formBuilder = $form_builder;
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container->get('form_builder'), $container->get('entity_type.manager'));
}
/**
* {@inheritdoc}
*/
public function build() {
$build = [
'form' => $this->formBuilder
->getForm(WorkspaceSwitcherForm::class),
'#cache' => [
'contexts' => $this->entityTypeManager
->getDefinition('workspace')
->getListCacheContexts(),
'tags' => $this->entityTypeManager
->getDefinition('workspace')
->getListCacheTags(),
],
];
return $build;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
WorkspaceSwitcherBlock::$entityTypeManager | protected | property | The entity type manager. | |
WorkspaceSwitcherBlock::$formBuilder | protected | property | The form builder. | |
WorkspaceSwitcherBlock::build | public | function | ||
WorkspaceSwitcherBlock::create | public static | function | Creates an instance of the plugin. | Overrides ContainerFactoryPluginInterface::create |
WorkspaceSwitcherBlock::__construct | public | function | Constructs a new WorkspaceSwitcherBlock instance. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.