class AddBlockForm in Drupal 8
Same name and namespace in other branches
- 9 core/modules/layout_builder/src/Form/AddBlockForm.php \Drupal\layout_builder\Form\AddBlockForm
Provides a form to add a block.
@internal Form classes are internal.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\layout_builder\Form\ConfigureBlockFormBase implements BaseFormIdInterface uses AjaxFormHelperTrait, ContextAwarePluginAssignmentTrait, LayoutBuilderContextTrait, LayoutRebuildTrait
- class \Drupal\layout_builder\Form\AddBlockForm uses LayoutBuilderHighlightTrait
- class \Drupal\layout_builder\Form\ConfigureBlockFormBase implements BaseFormIdInterface uses AjaxFormHelperTrait, ContextAwarePluginAssignmentTrait, LayoutBuilderContextTrait, LayoutRebuildTrait
Expanded class hierarchy of AddBlockForm
1 string reference to 'AddBlockForm'
- layout_builder.routing.yml in core/
modules/ layout_builder/ layout_builder.routing.yml - core/modules/layout_builder/layout_builder.routing.yml
File
- core/
modules/ layout_builder/ src/ Form/ AddBlockForm.php, line 16
Namespace
Drupal\layout_builder\FormView source
class AddBlockForm extends ConfigureBlockFormBase {
use LayoutBuilderHighlightTrait;
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'layout_builder_add_block';
}
/**
* {@inheritdoc}
*/
protected function submitLabel() {
return $this
->t('Add block');
}
/**
* Builds the form for the block.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
* @param \Drupal\layout_builder\SectionStorageInterface $section_storage
* The section storage being configured.
* @param int $delta
* The delta of the section.
* @param string $region
* The region of the block.
* @param string|null $plugin_id
* The plugin ID of the block to add.
*
* @return array
* The form array.
*/
public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, $delta = NULL, $region = NULL, $plugin_id = NULL) {
// Only generate a new component once per form submission.
if (!($component = $form_state
->get('layout_builder__component'))) {
$component = new SectionComponent($this->uuidGenerator
->generate(), $region, [
'id' => $plugin_id,
]);
$section_storage
->getSection($delta)
->appendComponent($component);
$form_state
->set('layout_builder__component', $component);
}
$form['#attributes']['data-layout-builder-target-highlight-id'] = $this
->blockAddHighlightId($delta, $region);
return $this
->doBuildForm($form, $form_state, $section_storage, $delta, $component);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AddBlockForm:: |
public | function |
Builds the form for the block. Overrides FormInterface:: |
|
AddBlockForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
AddBlockForm:: |
protected | function |
Returns the label for the submit button. Overrides ConfigureBlockFormBase:: |
|
AjaxFormHelperTrait:: |
public | function | Submit form dialog #ajax callback. | |
AjaxHelperTrait:: |
protected | function | Gets the wrapper format of the current request. | |
AjaxHelperTrait:: |
protected | function | Determines if the current request is via AJAX. | |
ConfigureBlockFormBase:: |
protected | property | The plugin being configured. | |
ConfigureBlockFormBase:: |
protected | property | The block manager. | |
ConfigureBlockFormBase:: |
protected | property | The field delta. | |
ConfigureBlockFormBase:: |
protected | property | The layout tempstore repository. | |
ConfigureBlockFormBase:: |
protected | property | The plugin form manager. | |
ConfigureBlockFormBase:: |
protected | property | The current region. | |
ConfigureBlockFormBase:: |
protected | property | The section storage. | |
ConfigureBlockFormBase:: |
protected | property | The UUID of the component. | |
ConfigureBlockFormBase:: |
protected | property | The UUID generator. | |
ConfigureBlockFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
|
ConfigureBlockFormBase:: |
public | function | Builds the form for the block. | |
ConfigureBlockFormBase:: |
public | function |
Returns a string identifying the base form. Overrides BaseFormIdInterface:: |
|
ConfigureBlockFormBase:: |
public | function | Retrieves the current component being edited by the form. | |
ConfigureBlockFormBase:: |
public | function | Retrieves the current layout section being edited by the form. | |
ConfigureBlockFormBase:: |
protected | function | Retrieves the plugin form for a given block. | |
ConfigureBlockFormBase:: |
public | function | Retrieves the section storage object. | |
ConfigureBlockFormBase:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
ConfigureBlockFormBase:: |
protected | function |
Allows the form to respond to a successful AJAX submission. Overrides AjaxFormHelperTrait:: |
|
ConfigureBlockFormBase:: |
public | function |
Form validation handler. Overrides FormBase:: |
|
ConfigureBlockFormBase:: |
public | function | Constructs a new block form. | |
ContextAwarePluginAssignmentTrait:: |
protected | function | Builds a form element for assigning a context to a given slot. | |
ContextAwarePluginAssignmentTrait:: |
protected | function | Wraps the context handler. | |
ContextAwarePluginAssignmentTrait:: |
abstract protected | function | Ensures the t() method is available. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Retrieves a configuration object. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
LayoutBuilderContextTrait:: |
protected | property | The context repository. | |
LayoutBuilderContextTrait:: |
protected | function | Gets the context repository service. | |
LayoutBuilderContextTrait:: |
protected | function | Provides all available contexts, both global and section_storage-specific. | |
LayoutBuilderHighlightTrait:: |
protected | function | Provides the ID used to highlight the active Layout Builder UI element. | |
LayoutBuilderHighlightTrait:: |
protected | function | Provides the ID used to highlight the active Layout Builder UI element. | |
LayoutBuilderHighlightTrait:: |
protected | function | Provides the ID used to highlight the active Layout Builder UI element. | |
LayoutBuilderHighlightTrait:: |
protected | function | Provides the ID used to highlight the active Layout Builder UI element. | |
LayoutRebuildTrait:: |
protected | function | Rebuilds the layout. | |
LayoutRebuildTrait:: |
protected | function | Rebuilds the layout. | |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |