RenderDeprecationController.php

Namespace

Drupal\render_deprecation

File

core/modules/system/tests/modules/render_deprecation/src/RenderDeprecationController.php

View source
<?php

namespace Drupal\render_deprecation;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Response;
class RenderDeprecationController implements ContainerAwareInterface {
    use ContainerAwareTrait;
    protected function renderArray() {
        return [
            'div' => [
                '#type' => 'container',
                '#attributes' => [
                    'id' => 'render-deprecation-test-result',
                ],
                'info' => [
                    '#markup' => 'Hello.',
                ],
            ],
        ];
    }
    public function buildRenderFunction() {
        $build = $this->renderArray();
        $render = render($build);
        return Response::create($render);
    }
    public function buildRenderService() {
        $build = $this->renderArray();
        $render = $this->container
            ->get('renderer')
            ->render($build);
        return Response::create($render);
    }

}

Classes

Title Deprecated Summary
RenderDeprecationController

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