class PanelsEverywhereDisplayVariant in Panels Everywhere 8
Same name and namespace in other branches
- 8.4 src/Plugin/DisplayVariant/PanelsEverywhereDisplayVariant.php \Drupal\panels_everywhere\Plugin\DisplayVariant\PanelsEverywhereDisplayVariant
Provides a display variant that simply contains blocks.
@todo: This shouldn't be necessary - the PanelsDisplayVariant should implement PageVariantInterface, because, it's easy and then it can be used to render the full page.
Plugin annotation
@DisplayVariant(
id = "panels_everywhere_variant",
admin_label = @Translation("Panels Everywhere")
)
Hierarchy
- class \Drupal\panels_everywhere\Plugin\DisplayVariant\PanelsEverywhereDisplayVariant extends \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant implements PageVariantInterface
Expanded class hierarchy of PanelsEverywhereDisplayVariant
File
- src/
Plugin/ DisplayVariant/ PanelsEverywhereDisplayVariant.php, line 21
Namespace
Drupal\panels_everywhere\Plugin\DisplayVariantView source
class PanelsEverywhereDisplayVariant extends PanelsDisplayVariant implements PageVariantInterface {
/**
* The render array representing the main page content.
*
* @var array
*/
protected $mainContent = [];
/**
* The title for the display variant.
*
* @var string
*/
protected $title;
/**
* Sets the title for the page being rendered.
*
* @param string|array $title
* The page title: either a string for plain titles or a render array for
* formatted titles.
*
* @return $this
*/
public function setTitle($title) {
$this->title = $title;
return $this;
}
/**
* {@inheritdoc}
*/
public function setMainContent(array $main_content) {
$this->mainContent = $main_content;
return $this;
}
/**
* {@inheritdoc}
*/
public function build() {
$main_content_included = NULL;
$this
->setPageTitle($this->title);
foreach ($this
->getRegionAssignments() as $region => $blocks) {
if (!$blocks) {
continue;
}
foreach ($blocks as $block_id => $block) {
if ($block instanceof MainContentBlockPluginInterface) {
$block
->setMainContent($this->mainContent);
$main_content_included = array(
$region,
$block_id,
);
}
}
}
// Build it the render array!
$build = parent::build();
// Copied from BlockPageVariant.php.
// The main content block cannot be cached: it is a placeholder for the
// render array returned by the controller. It should be rendered as-is,
// with other placed blocks "decorating" it.
if (!empty($main_content_included)) {
list($region, $block_id) = $main_content_included;
unset($build[$region][$block_id]['#cache']['keys']);
}
return $build;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyInterface:: |
public | function | The cache contexts associated with this object. | 34 |
CacheableDependencyInterface:: |
public | function | The maximum age for which this object may be cached. | 34 |
CacheableDependencyInterface:: |
public | function | The cache tags associated with this object. | 27 |
ConfigurableInterface:: |
public | function | Gets default configuration for this plugin. | 11 |
ConfigurableInterface:: |
public | function | Gets this plugin's configuration. | 12 |
ConfigurableInterface:: |
public | function | Sets the configuration for this plugin instance. | 12 |
DependentPluginInterface:: |
public | function | Calculates dependencies for the configured plugin. | 19 |
PanelsEverywhereDisplayVariant:: |
protected | property | The render array representing the main page content. | |
PanelsEverywhereDisplayVariant:: |
protected | property | The title for the display variant. | |
PanelsEverywhereDisplayVariant:: |
public | function |
Builds and returns the renderable array for the display variant. Overrides VariantInterface:: |
|
PanelsEverywhereDisplayVariant:: |
public | function |
Sets the main content for the page being rendered. Overrides PageVariantInterface:: |
|
PanelsEverywhereDisplayVariant:: |
public | function |
Sets the title for the page being rendered. Overrides PageVariantInterface:: |
|
PluginFormInterface:: |
public | function | Form constructor. | 36 |
PluginFormInterface:: |
public | function | Form submission handler. | 32 |
PluginFormInterface:: |
public | function | Form validation handler. | 18 |
PluginInspectionInterface:: |
public | function | Gets the definition of the plugin implementation. | 4 |
PluginInspectionInterface:: |
public | function | Gets the plugin_id of the plugin instance. | 2 |
RefinableCacheableDependencyInterface:: |
public | function | Adds a dependency on an object: merges its cacheability metadata. | 1 |
RefinableCacheableDependencyInterface:: |
public | function | Adds cache contexts. | 1 |
RefinableCacheableDependencyInterface:: |
public | function | Adds cache tags. | 1 |
RefinableCacheableDependencyInterface:: |
public | function | Merges the maximum age (in seconds) with the existing maximum age. | 1 |
VariantInterface:: |
public | function | Determines if this display variant is accessible. | 1 |
VariantInterface:: |
public | function | Returns the admin-facing display variant label. | 1 |
VariantInterface:: |
public | function | Returns the weight of the display variant. | 1 |
VariantInterface:: |
public | function | Returns the unique ID for the display variant. | 1 |
VariantInterface:: |
public | function | Returns the user-facing display variant label. | 1 |
VariantInterface:: |
public | function | Sets the weight of the display variant. | 1 |