function RenderExampleController::postRenderAddPrefix

Same name in other branches
  1. 8.x-1.x render_example/src/Controller/RenderExampleController.php \Drupal\render_example\Controller\RenderExampleController::postRenderAddPrefix()
  2. 4.0.x modules/render_example/src/Controller/RenderExampleController.php \Drupal\render_example\Controller\RenderExampleController::postRenderAddPrefix()

Example '#post_render' callback function.

Post render callbacks are triggered after an element has been rendered to HTML and can act upon the final rendered string.

This function is used as a post render callback in Drupal\render_example\Controller\RenderExampleController::arrays().

Parameters

string $markup: The rendered element.

array $element: The element which was rendered (for reference)

Return value

string Markup altered as necessary. In this case we add a little postscript.

See also

\Drupal\render_example\Controller\RenderExampleController::arrays()

File

modules/render_example/src/Controller/RenderExampleController.php, line 519

Class

RenderExampleController
Provides module description page and examples of building render arrays.

Namespace

Drupal\render_example\Controller

Code

public static function postRenderAddPrefix($markup, array $element) {
    $markup .= '<div style="color:blue">This markup was added after rendering by a #post_render callback.</div>';
    return $markup;
}