3 namespace Drupal\Core\Render\Plugin\DisplayVariant;
5 use Drupal\Core\Display\PageVariantInterface;
6 use Drupal\Core\Display\VariantBase;
9 * Provides a page display variant that simply renders the main content.
11 * @PageDisplayVariant(
13 * admin_label = @Translation("Simple page")
16 class SimplePageVariant extends VariantBase implements PageVariantInterface {
19 * The render array representing the main content.
23 protected $mainContent;
26 * The page title: a string (plain title) or a render array (formatted title).
30 protected $title = '';
35 public function setMainContent(array $main_content) {
36 $this->mainContent = $main_content;
43 public function setTitle($title) {
44 $this->title = $title;
51 public function build() {
55 '#type' => 'status_messages',
59 '#type' => 'page_title',
60 '#title' => $this->title,
63 'main_content' => ['#weight' => -800] + $this->mainContent,