protected function RenderPlaceholderMessageTestController::build in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php \Drupal\render_placeholder_message_test\RenderPlaceholderMessageTestController::build()
Return value
array
3 calls to RenderPlaceholderMessageTestController::build()
- RenderPlaceholderMessageTestController::messagesPlaceholderFirst in core/
modules/ system/ tests/ modules/ render_placeholder_message_test/ src/ RenderPlaceholderMessageTestController.php - RenderPlaceholderMessageTestController::messagesPlaceholderLast in core/
modules/ system/ tests/ modules/ render_placeholder_message_test/ src/ RenderPlaceholderMessageTestController.php - RenderPlaceholderMessageTestController::messagesPlaceholderMiddle in core/
modules/ system/ tests/ modules/ render_placeholder_message_test/ src/ RenderPlaceholderMessageTestController.php
File
- core/
modules/ system/ tests/ modules/ render_placeholder_message_test/ src/ RenderPlaceholderMessageTestController.php, line 57
Class
Namespace
Drupal\render_placeholder_message_testCode
protected function build(array $placeholder_order) {
$build = [];
$build['messages'] = [
'#type' => 'status_messages',
];
$build['p1'] = [
'#lazy_builder' => [
'\\Drupal\\render_placeholder_message_test\\RenderPlaceholderMessageTestController::setAndLogMessage',
[
'P1',
],
],
'#create_placeholder' => TRUE,
];
$build['p2'] = [
'#lazy_builder' => [
'\\Drupal\\render_placeholder_message_test\\RenderPlaceholderMessageTestController::setAndLogMessage',
[
'P2',
],
],
'#create_placeholder' => TRUE,
];
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container
->get('renderer');
$renderer
->executeInRenderContext(new RenderContext(), function () use (&$build, $renderer) {
return $renderer
->render($build, FALSE);
});
$reordered = [];
foreach ($placeholder_order as $placeholder) {
$reordered[$placeholder] = $build['#attached']['placeholders'][$placeholder];
}
$build['#attached']['placeholders'] = $reordered;
return $build;
}