Skip to content
Snippets Groups Projects
Commit 4c440880 authored by Pierre Dureau's avatar Pierre Dureau Committed by Florent Torregrosa
Browse files

Issue #3484571 by grimreaper, pdureau, mh_nichts: Manage layouts regions

parent b207110d
No related branches found
No related tags found
1 merge request!20Issue #3484571 by mh_nichts, pdureau: Manage layouts regions
Pipeline #410548 passed
......@@ -68,6 +68,13 @@ class ExampleSyntaxConverter implements ExampleSyntaxConverterInterface {
'type',
'value',
];
$in_layout = (isset($renderable['theme']) && \explode('__', $renderable['theme'])[0] === 'layout');
$layout_allowed_render_keys = [
'attached',
'attributes',
'theme',
'settings',
];
foreach ($renderable as $property => $value) {
if (!\is_string($property)) {
continue;
......@@ -76,6 +83,10 @@ class ExampleSyntaxConverter implements ExampleSyntaxConverterInterface {
if ($in_html_tag && !\in_array($property, $html_tag_allowed_render_keys, TRUE)) {
continue;
}
// Layouts are special.
if ($in_layout && !\in_array($property, $layout_allowed_render_keys, TRUE)) {
continue;
}
if (\str_starts_with($property, '#')) {
continue;
}
......
......@@ -33,6 +33,7 @@ final class ExampleSyntaxConverterTest extends UnitTestCase {
'Not convertible' => self::notConvertible(),
'Status messages' => self::statusMessages(),
'Theme image' => self::themeImage(),
'Theme layout' => self::themeLayout(),
];
foreach ($data as $label => $test) {
yield $label => [
......@@ -209,4 +210,62 @@ final class ExampleSyntaxConverterTest extends UnitTestCase {
];
}
/**
* Theme layout.
*/
protected static function themeLayout(): array {
$value = [
[
'theme' => 'layout',
'my_region' => [
'markup' => 'my markup',
],
'attributes' => [
'class' => [
'my-class',
],
],
],
[
'theme' => 'layout__my_theme',
'my_region' => [
'markup' => 'my markup',
],
'attributes' => [
'class' => [
'my-class',
],
],
],
];
$expected = [
[
'#theme' => 'layout',
'my_region' => [
'#markup' => 'my markup',
],
'#attributes' => [
'class' => [
'my-class',
],
],
],
[
'#theme' => 'layout__my_theme',
'my_region' => [
'#markup' => 'my markup',
],
'#attributes' => [
'class' => [
'my-class',
],
],
],
];
return [
'value' => $value,
'expected' => $expected,
];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment