LayoutBuilder
class LayoutBuilder extends RenderElement implements ContainerFactoryPluginInterface (View source)
| internal | Plugin classes are internal. |
Defines a render element for building the Layout Builder UI.
Traits
Provides a helper to determine if the current request is via AJAX.
Provides a wrapper around getting contexts from a section storage object.
A trait for generating IDs used to highlight active UI elements.
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Provides dependency injection friendly methods for serialization.
Provides a trait for the messenger service.
Constants
| DERIVATIVE_SEPARATOR |
A string which is used to separate base plugin IDs from the derivative ID. |
Properties
| protected string | $pluginId | The plugin_id. |
from PluginBase |
| protected array | $pluginDefinition | The plugin implementation definition. |
from PluginBase |
| protected array | $configuration | Configuration information passed into the plugin. |
from PluginBase |
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| 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 MessengerInterface | $messenger | The messenger. |
from MessengerTrait |
| protected ContextRepositoryInterface | $contextRepository | The context repository. |
from LayoutBuilderContextTrait |
| protected EventDispatcherInterface | $eventDispatcher | The event dispatcher. |
Methods
Constructs a new LayoutBuilder.
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.
Sets a form element's class attribute.
Adds members of this group as actual elements for rendering.
Form element processing handler for the #ajax form property.
Adds Ajax information about an element to communicate with JavaScript.
Arranges elements into groups.
Gets the wrapper format of the current request.
Gets the context repository service.
Provides all available contexts, both global and section_storage-specific.
Returns all populated contexts, both global and section-storage-specific.
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.
Creates an instance of the plugin.
Returns the element properties for this element.
Pre-render callback: Renders the Layout Builder UI.
Builds a link to add a new section at a given delta.
Builds the render array for the layout section while editing.
Details
__construct(array $configuration, string $plugin_id, mixed $plugin_definition, EventDispatcherInterface $event_dispatcher, MessengerInterface|null $messenger = NULL)
Constructs a new LayoutBuilder.
string
getPluginId()
Gets the plugin_id of the plugin instance.
string
getBaseId()
Gets the base_plugin_id of the plugin instance.
string|null
getDerivativeId()
Gets the derivative_id of the plugin instance.
array
getPluginDefinition()
Gets the definition of the plugin implementation.
bool
isConfigurable()
Determines if the plugin is configurable.
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.
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
setMessenger(MessengerInterface $messenger)
Sets the messenger.
MessengerInterface
messenger()
Gets the messenger.
static
setAttributes(array $element, array $class = [])
Sets a form element's class attribute.
Adds 'required' and 'error' classes as needed.
static array
preRenderGroup(array $element)
Adds members of this group as actual elements for rendering.
static array
processAjaxForm(array $element, FormStateInterface $form_state, array $complete_form)
Form element processing handler for the #ajax form property.
This method is useful for non-input elements that can be used in and outside the context of a form.
static array
preRenderAjaxForm(array $element)
Adds Ajax information about an element to communicate with JavaScript.
If #ajax is set on an element, this additional JavaScript is added to the page header to attach the Ajax behaviors. See ajax.js for more information.
static array
processGroup(array $element, FormStateInterface $form_state, array $complete_form)
Arranges elements into groups.
This method is useful for non-input elements that can be used in and outside the context of a form.
protected bool
isAjax()
Determines if the current request is via AJAX.
protected string|null
getRequestWrapperFormat()
Gets the wrapper format of the current request.
protected ContextRepositoryInterface
contextRepository()
Gets the context repository service.
protected ContextInterface[]
getAvailableContexts(SectionStorageInterface $section_storage)
deprecated
deprecated
Provides all available contexts, both global and section_storage-specific.
protected array
getPopulatedContexts(SectionStorageInterface $section_storage)
Returns all populated contexts, both global and section-storage-specific.
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.
static ContainerFactoryPluginInterface
create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition)
Creates an instance of the plugin.
array
getInfo()
Returns the element properties for this element.
preRender($element)
Pre-render callback: Renders the Layout Builder UI.
protected array
layout(SectionStorageInterface $section_storage)
Renders the Layout UI.
protected
prepareLayout(SectionStorageInterface $section_storage)
Prepares a layout for use in the UI.
protected array
buildAddSectionLink(SectionStorageInterface $section_storage, int $delta)
Builds a link to add a new section at a given delta.
protected array
buildAdministrativeSection(SectionStorageInterface $section_storage, int $delta)
Builds the render array for the layout section while editing.