public static function RenderExampleController::postRenderAddPrefix in Examples for Developers 8
Same name and namespace in other branches
- 3.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
- render_example/
src/ Controller/ RenderExampleController.php, line 519
Class
- RenderExampleController
- Provides module description page and examples of building render arrays.
Namespace
Drupal\render_example\ControllerCode
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;
}