class SimplePageVariant
Same name in other branches
- 9 core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php \Drupal\Core\Render\Plugin\DisplayVariant\SimplePageVariant
- 8.9.x core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php \Drupal\Core\Render\Plugin\DisplayVariant\SimplePageVariant
- 11.x core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php \Drupal\Core\Render\Plugin\DisplayVariant\SimplePageVariant
Provides a page display variant that simply renders the main content.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\Core\Display\VariantBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Display\VariantInterface uses \Drupal\Core\Plugin\PluginDependencyTrait, \Drupal\Core\Cache\RefinableCacheableDependencyTrait
- class \Drupal\Core\Render\Plugin\DisplayVariant\SimplePageVariant extends \Drupal\Core\Display\VariantBase implements \Drupal\Core\Display\PageVariantInterface
- class \Drupal\Core\Display\VariantBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Display\VariantInterface uses \Drupal\Core\Plugin\PluginDependencyTrait, \Drupal\Core\Cache\RefinableCacheableDependencyTrait
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of SimplePageVariant
File
-
core/
lib/ Drupal/ Core/ Render/ Plugin/ DisplayVariant/ SimplePageVariant.php, line 13
Namespace
Drupal\Core\Render\Plugin\DisplayVariantView source
class SimplePageVariant extends VariantBase implements PageVariantInterface {
/**
* The render array representing the main content.
*
* @var array
*/
protected $mainContent;
/**
* The page title: a string (plain title) or a render array (formatted title).
*
* @var string|array
*/
protected $title = '';
/**
* {@inheritdoc}
*/
public function setMainContent(array $main_content) {
$this->mainContent = $main_content;
return $this;
}
/**
* {@inheritdoc}
*/
public function setTitle($title) {
$this->title = $title;
return $this;
}
/**
* {@inheritdoc}
*/
public function build() {
$build = [
'content' => [
'messages' => [
'#type' => 'status_messages',
'#weight' => -1000,
'#include_fallback' => TRUE,
],
'page_title' => [
'#type' => 'page_title',
'#title' => $this->title,
'#weight' => -900,
],
'main_content' => [
'#weight' => -800,
] + $this->mainContent,
],
];
return $build;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.