AddBlockForm
class AddBlockForm extends ConfigureBlockFormBase (View source)
| internal | Form classes are internal. |
Provides a form to add a block.
Traits
A trait for generating IDs used to highlight active UI elements.
Provides a helper to for submitting an AJAX form.
Handles context assignments for context-aware plugins.
Provides a wrapper around getting contexts from a section storage object.
Provides AJAX responses to rebuild the Layout Builder.
Provides a helper to determine if the current request is via AJAX.
Provides dependency injection friendly methods for serialization.
Wrapper methods for the logger factory service.
Provides a trait for the messenger service.
Wrapper methods for the Redirect Destination.
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Properties
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected LoggerChannelFactoryInterface | $loggerFactory | The logger channel factory service. |
from LoggerChannelTrait |
| protected MessengerInterface | $messenger | The messenger. |
from MessengerTrait |
| protected RedirectDestinationInterface | $redirectDestination | The redirect destination service. |
from RedirectDestinationTrait |
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected RequestStack | $requestStack | The request stack. |
from FormBase |
| protected ConfigFactoryInterface | $configFactory | The config factory. |
from FormBase |
| protected RouteMatchInterface | $routeMatch | The route match. |
from FormBase |
| protected ContextRepositoryInterface | $contextRepository | The context repository. |
from LayoutBuilderContextTrait |
| protected BlockPluginInterface | $block | The plugin being configured. |
from ConfigureBlockFormBase |
| protected LayoutTempstoreRepositoryInterface | $layoutTempstoreRepository | The layout tempstore repository. |
from ConfigureBlockFormBase |
| protected BlockManagerInterface | $blockManager | The block manager. |
from ConfigureBlockFormBase |
| protected UuidInterface | $uuidGenerator | The UUID generator. |
from ConfigureBlockFormBase |
| protected PluginFormFactoryInterface | $pluginFormFactory | The plugin form manager. |
from ConfigureBlockFormBase |
| protected int | $delta | The field delta. |
from ConfigureBlockFormBase |
| protected string | $region | The current region. |
from ConfigureBlockFormBase |
| protected string | $uuid | The UUID of the component. |
from ConfigureBlockFormBase |
| protected SectionStorageInterface | $sectionStorage | The section storage. |
from ConfigureBlockFormBase |
Methods
Gets the logger for a specific channel.
Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
Returns the redirect destination service.
Sets the redirect destination service.
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Instantiates a new instance of this class.
Sets the request stack object to use.
Returns a redirect response object for the specified route.
Allows the form to respond to a successful AJAX submission.
Wraps the context handler.
Builds a form element for assigning a context to a given slot.
Gets the context repository service.
Provides all available contexts, both global and section_storage-specific.
Constructs a new block form.
Builds the form for the block.
Returns the label for the submit button.
Retrieves the section storage object.
Retrieves the current layout section being edited by the form.
Retrieves the current component being edited by the form.
Provides the ID used to highlight the active Layout Builder UI element.
Provides the ID used to highlight the active Layout Builder UI element.
Provides the ID used to highlight the active Layout Builder UI element.
Provides the ID used to highlight the active Layout Builder UI element.
Returns a unique string identifying the form.
Builds the form for the block.
Details
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
protected LoggerInterface
getLogger(string $channel)
Gets the logger for a specific channel.
$this
setLoggerFactory(LoggerChannelFactoryInterface $logger_factory)
Injects the logger channel factory.
setMessenger(MessengerInterface $messenger)
Sets the messenger.
MessengerInterface
messenger()
Gets the messenger.
protected array
getDestinationArray()
Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
protected RedirectDestinationInterface
getRedirectDestination()
Returns the redirect destination service.
$this
setRedirectDestination(RedirectDestinationInterface $redirect_destination)
Sets the redirect destination service.
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
static
create(ContainerInterface $container)
Instantiates a new instance of this class.
This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.
validateForm(array $form, FormStateInterface $form_state)
Form validation handler.
protected ImmutableConfig
config(string $name)
Retrieves a configuration object.
This is the main entry point to the configuration API. Calling
protected ConfigFactoryInterface
configFactory()
Gets the config factory for this form.
When accessing configuration values, use $this->config(). Only use this when the config factory needs to be manipulated directly.
$this
setConfigFactory(ConfigFactoryInterface $config_factory)
Sets the config factory for this form.
resetConfigFactory()
Resets the configuration factory.
protected Request
getRequest()
Gets the request object.
protected RouteMatchInterface
getRouteMatch()
Gets the route match.
$this
setRequestStack(RequestStack $request_stack)
Sets the request stack object to use.
protected AccountInterface
currentUser()
Gets the current user.
protected RedirectResponse
redirect(string $route_name, array $route_parameters = [], array $options = [], int $status = 302)
Returns a redirect response object for the specified route.
protected LoggerInterface
logger(string $channel)
Gets the logger for a specific channel.
This method exists for backward-compatibility between FormBase and LoggerChannelTrait. Use LoggerChannelTrait::getLogger() instead.
protected bool
isAjax()
Determines if the current request is via AJAX.
protected
getRequestWrapperFormat()
Gets the wrapper format of the current request.
AjaxResponse
ajaxSubmit(array $form, FormStateInterface $form_state)
Submit form dialog #ajax callback.
abstract protected AjaxResponse
successfulAjaxSubmit(array $form, FormStateInterface $form_state)
Allows the form to respond to a successful AJAX submission.
protected ContextHandlerInterface
contextHandler()
Wraps the context handler.
protected array
addContextAssignmentElement(ContextAwarePluginInterface $plugin, array $contexts)
Builds a form element for assigning a context to a given slot.
protected ContextRepositoryInterface
contextRepository()
Gets the context repository service.
protected ContextInterface[]
getAvailableContexts(SectionStorageInterface $section_storage)
Provides all available contexts, both global and section_storage-specific.
protected AjaxResponse
rebuildAndClose(SectionStorageInterface $section_storage)
Rebuilds the layout.
protected AjaxResponse
rebuildLayout(SectionStorageInterface $section_storage)
Rebuilds the layout.
__construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, ContextRepositoryInterface $context_repository, BlockManagerInterface $block_manager, UuidInterface $uuid, PluginFormFactoryInterface $plugin_form_manager)
Constructs a new block form.
string|null
getBaseFormId()
Returns a string identifying the base form.
array
doBuildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, int $delta = NULL, SectionComponent $component = NULL)
Builds the form for the block.
protected string
submitLabel()
Returns the label for the submit button.
submitForm(array $form, FormStateInterface $form_state)
Form submission handler.
protected PluginFormInterface
getPluginForm(BlockPluginInterface $block)
Retrieves the plugin form for a given block.
SectionStorageInterface
getSectionStorage()
Retrieves the section storage object.
Section
getCurrentSection()
Retrieves the current layout section being edited by the form.
SectionComponent
getCurrentComponent()
Retrieves the current component being edited by the form.
protected string
blockAddHighlightId(string $delta, string $region)
Provides the ID used to highlight the active Layout Builder UI element.
protected string
blockUpdateHighlightId(string $uuid)
Provides the ID used to highlight the active Layout Builder UI element.
protected string
sectionAddHighlightId(string $delta)
Provides the ID used to highlight the active Layout Builder UI element.
protected string
sectionUpdateHighlightId(string $delta)
Provides the ID used to highlight the active Layout Builder UI element.
string
getFormId()
Returns a unique string identifying the form.
The returned ID should be a unique string that can be a valid PHP function name, since it's used in hook implementation names such as hook_form_FORM_ID_alter().
array
buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, int $delta = NULL, string $region = NULL, string|null $plugin_id = NULL)
Builds the form for the block.