function SimplePageVariant::build

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php \Drupal\Core\Render\Plugin\DisplayVariant\SimplePageVariant::build()
  2. 8.9.x core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php \Drupal\Core\Render\Plugin\DisplayVariant\SimplePageVariant::build()
  3. 11.x core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php \Drupal\Core\Render\Plugin\DisplayVariant\SimplePageVariant::build()

Builds and returns the renderable array for the display variant.

The variant can contain cacheability metadata for the configuration that was passed in setConfiguration(). In the build() method, this should be added to the render array that is returned.

Return value

array A render array for the display variant.

Overrides VariantInterface::build

File

core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php, line 52

Class

SimplePageVariant
Provides a page display variant that simply renders the main content.

Namespace

Drupal\Core\Render\Plugin\DisplayVariant

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.