abstract class BlockBase in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Block/BlockBase.php \Drupal\Core\Block\BlockBase
- 9 core/lib/Drupal/Core/Block/BlockBase.php \Drupal\Core\Block\BlockBase
Defines a base block implementation that most blocks plugins will extend.
This abstract class provides the generic block configuration form, default block settings, and handling for general user-defined block visibility settings.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\Core\Block\BlockBase implements BlockPluginInterface, ContextAwarePluginInterface, PluginWithFormsInterface, PreviewAwarePluginInterface, PreviewFallbackInterface uses BlockPluginTrait, ContextAwarePluginAssignmentTrait, ContextAwarePluginTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of BlockBase
Related topics
48 files declare their use of BlockBase
- AjaxFormBlock.php in core/
modules/ system/ tests/ modules/ ajax_forms_test/ src/ Plugin/ Block/ AjaxFormBlock.php - AttachedRenderingBlock.php in core/
modules/ system/ tests/ modules/ render_attached_test/ src/ Plugin/ Block/ AttachedRenderingBlock.php - BlockContentBlock.php in core/
modules/ block_content/ src/ Plugin/ Block/ BlockContentBlock.php - BlockFormTest.php in core/
modules/ block/ tests/ src/ Unit/ BlockFormTest.php - BookNavigationBlock.php in core/
modules/ book/ src/ Plugin/ Block/ BookNavigationBlock.php
File
- core/
lib/ Drupal/ Core/ Block/ BlockBase.php, line 23
Namespace
Drupal\Core\BlockView source
abstract class BlockBase extends PluginBase implements BlockPluginInterface, PluginWithFormsInterface, PreviewAwarePluginInterface, PreviewFallbackInterface, ContextAwarePluginInterface {
use BlockPluginTrait {
buildConfigurationForm as traitBuildConfigurationForm;
}
use ContextAwarePluginTrait;
use ContextAwarePluginAssignmentTrait;
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = $this
->traitBuildConfigurationForm($form, $form_state);
// Add context mapping UI form elements.
$contexts = $form_state
->getTemporaryValue('gathered_contexts') ?: [];
$form['context_mapping'] = $this
->addContextAssignmentElement($this, $contexts);
return $form;
}
}