class LayoutBuilderDisplayVariant in Page Manager 8.4
Provides a Layout Builder variant.
Plugin annotation
@DisplayVariant(
id = "layout_builder",
admin_label = @Translation("Layout Builder")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\Core\Display\VariantBase implements VariantInterface uses RefinableCacheableDependencyTrait, PluginDependencyTrait
- class \Drupal\page_manager\Plugin\DisplayVariant\LayoutBuilderDisplayVariant implements ContextAwareVariantInterface, PluginWizardInterface uses LayoutEntityHelperTrait, SectionStorageTrait
- class \Drupal\Core\Display\VariantBase implements VariantInterface uses RefinableCacheableDependencyTrait, PluginDependencyTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of LayoutBuilderDisplayVariant
2 files declare their use of LayoutBuilderDisplayVariant
- PageManagerLayoutBuilderStorage.php in src/
Plugin/ LayoutBuilderStorage/ PageManagerLayoutBuilderStorage.php - PageManagerSectionStorage.php in src/
Plugin/ SectionStorage/ PageManagerSectionStorage.php
File
- src/
Plugin/ DisplayVariant/ LayoutBuilderDisplayVariant.php, line 21
Namespace
Drupal\page_manager\Plugin\DisplayVariantView source
class LayoutBuilderDisplayVariant extends VariantBase implements PluginWizardInterface, ContextAwareVariantInterface {
use SectionStorageTrait;
use LayoutEntityHelperTrait;
/**
* An array of collected contexts.
*
* This is only used on runtime, and is not stored.
*
* @var \Drupal\Component\Plugin\Context\ContextInterface[]
*/
protected $contexts = [];
/**
* {@inheritdoc}
*/
public function build() {
$build = [];
$contexts = $this
->getContexts();
foreach ($this
->getSections() as $delta => $section) {
$build[$delta] = $section
->toRenderArray($contexts);
}
return $build;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return parent::defaultConfiguration() + [
'sections' => [],
];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return $form;
}
/**
* {@inheritdoc}
*/
public function getWizardOperations($cached_values) {
$operations = [];
$operations['layout_builder'] = [
'title' => $this
->t('Layout'),
'form' => LayoutBuilderForm::class,
];
return $operations;
}
/**
* {@inheritdoc}
*/
protected function setSections(array $sections) {
$this->configuration['sections'] = array_values($sections);
}
/**
* {@inheritdoc}
*/
public function getSections() {
if (!isset($this->configuration['sections'])) {
$this->configuration['sections'] = [];
}
return $this->configuration['sections'];
}
/**
* Returns instance of the layout plugin used by this page variant.
*
* @return \Drupal\Core\Layout\LayoutInterface
* A layout plugin instance.
*/
public function getLayout() {
if (!isset($this->layout)) {
$this->layout = $this->layoutManager
->createInstance($this->configuration['layout'], $this->configuration['layout_settings']);
}
return $this->layout;
}
/**
* {@inheritdoc}
*/
public function getContexts() {
return $this->contexts;
}
/**
* {@inheritdoc}
*/
public function setContexts(array $contexts) {
$this->contexts = $contexts;
return $this;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
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 | |
DependencyTrait:: |
protected | property | The object's dependencies. | |
DependencyTrait:: |
protected | function | Adds multiple dependencies. | |
DependencyTrait:: |
protected | function | Adds a dependency. | |
LayoutBuilderDisplayVariant:: |
protected | property | An array of collected contexts. | |
LayoutBuilderDisplayVariant:: |
public | function |
Builds and returns the renderable array for the display variant. Overrides VariantInterface:: |
|
LayoutBuilderDisplayVariant:: |
public | function |
Form constructor. Overrides VariantBase:: |
|
LayoutBuilderDisplayVariant:: |
public | function |
Gets default configuration for this plugin. Overrides VariantBase:: |
|
LayoutBuilderDisplayVariant:: |
public | function |
Gets the values for all defined contexts. Overrides ContextAwareVariantInterface:: |
|
LayoutBuilderDisplayVariant:: |
public | function | Returns instance of the layout plugin used by this page variant. | |
LayoutBuilderDisplayVariant:: |
public | function | ||
LayoutBuilderDisplayVariant:: |
public | function |
Retrieve a list of FormInterface classes by their step key in the wizard. Overrides PluginWizardInterface:: |
|
LayoutBuilderDisplayVariant:: |
public | function |
Sets the context values for this display variant. Overrides ContextAwareVariantInterface:: |
|
LayoutBuilderDisplayVariant:: |
protected | function |
Stores the information for all sections. Overrides SectionStorageTrait:: |
|
LayoutEntityHelperTrait:: |
protected | property | The section storage manager. | 1 |
LayoutEntityHelperTrait:: |
protected | function | Gets the sections for an entity if any. | |
LayoutEntityHelperTrait:: |
protected | function | Gets components that have Inline Block plugins. | |
LayoutEntityHelperTrait:: |
protected | function | Gets revision IDs for layout sections. | |
LayoutEntityHelperTrait:: |
protected | function | Gets the section storage for an entity. | |
LayoutEntityHelperTrait:: |
protected | function | Determines if an entity is using a field for the layout override. | |
LayoutEntityHelperTrait:: |
protected | function | Determines if an entity can have a layout. | |
LayoutEntityHelperTrait:: |
protected | function | Determines if the original entity used the default section storage. | |
LayoutEntityHelperTrait:: |
private | function | Gets the section storage manager. | 1 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginDependencyTrait:: |
protected | function | Calculates and adds dependencies of a specific plugin instance. | 1 |
PluginDependencyTrait:: |
protected | function | Calculates and returns dependencies of a specific plugin instance. | |
PluginDependencyTrait:: |
protected | function | Wraps the module handler. | 1 |
PluginDependencyTrait:: |
protected | function | Wraps the theme handler. | 1 |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
SectionStorageTrait:: |
protected | function | Adds a blank section to the list. | |
SectionStorageTrait:: |
public | function | ||
SectionStorageTrait:: |
public | function | ||
SectionStorageTrait:: |
public | function | ||
SectionStorageTrait:: |
protected | function | Indicates if this section list contains a blank section. | |
SectionStorageTrait:: |
protected | function | Indicates if there is a section at the specified delta. | |
SectionStorageTrait:: |
public | function | ||
SectionStorageTrait:: |
public | function | ||
SectionStorageTrait:: |
public | function | ||
SectionStorageTrait:: |
protected | function | Sets the section for the given delta on the display. | |
SectionStorageTrait:: |
public | function | Magic method: Implements a deep clone. | |
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 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
VariantBase:: |
public | function |
Determines if this display variant is accessible. Overrides VariantInterface:: |
|
VariantBase:: |
public | function |
Returns the admin-facing display variant label. Overrides VariantInterface:: |
|
VariantBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
VariantBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
VariantBase:: |
public | function |
Returns the weight of the display variant. Overrides VariantInterface:: |
|
VariantBase:: |
public | function |
Returns the unique ID for the display variant. Overrides VariantInterface:: |
|
VariantBase:: |
public | function |
Returns the user-facing display variant label. Overrides VariantInterface:: |
|
VariantBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
VariantBase:: |
public | function |
Sets the weight of the display variant. Overrides VariantInterface:: |
|
VariantBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
VariantBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
VariantBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
1 |