Skip to content
Snippets Groups Projects
Commit 3dea3843 authored by jurgenhaas's avatar jurgenhaas
Browse files

Revert "Update core patch"

This reverts commit 53404442.
parent e8eb6b8f
No related branches found
No related tags found
1 merge request!155Merging develop into main
Pipeline #1193365 passed with warnings
diff --git a/core/lib/Drupal/Core/Layout/LayoutDefault.php b/core/lib/Drupal/Core/Layout/LayoutDefault.php
index bd3780987a..8fc99d76ea 100644
index 607b34a48cd91bf740f3e6eda563a8de8b659467..bb97f8b42ffd61d185ed25eab2d91b12dc91c3d5 100644
--- a/core/lib/Drupal/Core/Layout/LayoutDefault.php
+++ b/core/lib/Drupal/Core/Layout/LayoutDefault.php
@@ -8,6 +8,7 @@
......@@ -18,7 +18,7 @@ index bd3780987a..8fc99d76ea 100644
/**
* Whether the plugin is being rendered in preview mode.
@@ -127,6 +129,13 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
@@ -126,6 +128,13 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
$this->configuration['label'] = $form_state->getValue('label');
}
......@@ -33,7 +33,7 @@ index bd3780987a..8fc99d76ea 100644
* {@inheritdoc}
*/
diff --git a/core/lib/Drupal/Core/Layout/LayoutInterface.php b/core/lib/Drupal/Core/Layout/LayoutInterface.php
index 33858a546d..2e62ba85da 100644
index 33858a546d7fc0f2696c408873f4b9bf51cb9b7c..2e62ba85da65ed7029abd5df9571348e9bfcd7fa 100644
--- a/core/lib/Drupal/Core/Layout/LayoutInterface.php
+++ b/core/lib/Drupal/Core/Layout/LayoutInterface.php
@@ -7,11 +7,12 @@
......@@ -51,7 +51,7 @@ index 33858a546d..2e62ba85da 100644
/**
* Build a render array for layout with regions.
diff --git a/core/modules/layout_builder/src/Controller/ChooseSectionController.php b/core/modules/layout_builder/src/Controller/ChooseSectionController.php
index 46b969e2f8..bc22d1f004 100644
index 46b969e2f8ba15a75da1be3b0f9a3bb71f30e138..bc22d1f004b7a828155a811758026e7d631a1ed9 100644
--- a/core/modules/layout_builder/src/Controller/ChooseSectionController.php
+++ b/core/modules/layout_builder/src/Controller/ChooseSectionController.php
@@ -4,8 +4,10 @@
......@@ -99,7 +99,7 @@ index 46b969e2f8..bc22d1f004 100644
'section_storage_type' => $section_storage->getStorageType(),
'section_storage' => $section_storage->getStorageId(),
diff --git a/core/modules/layout_builder/src/Element/LayoutBuilder.php b/core/modules/layout_builder/src/Element/LayoutBuilder.php
index 451927e540..8234a476ab 100644
index 5c91b1e39208a7895c6cb664c1f5e793c8d9522c..e8c83d975fd37c8c80af9f97b0fd47c942f1f615 100644
--- a/core/modules/layout_builder/src/Element/LayoutBuilder.php
+++ b/core/modules/layout_builder/src/Element/LayoutBuilder.php
@@ -3,8 +3,10 @@
......@@ -110,10 +110,10 @@ index 451927e540..8234a476ab 100644
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginFormInterface;
+use Drupal\Core\Plugin\PluginWithFormsInterface;
use Drupal\Core\Render\Attribute\RenderElement;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\RenderElement as RenderElementBase;
@@ -325,6 +327,7 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s
use Drupal\Core\Render\Element\RenderElement;
use Drupal\Core\Url;
@@ -337,6 +339,7 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s
$build['#attributes']['class'][] = 'layout-builder__layout';
$build['#attributes']['data-layout-builder-highlight-id'] = $this->sectionUpdateHighlightId($delta);
......@@ -121,7 +121,7 @@ index 451927e540..8234a476ab 100644
return [
'#type' => 'container',
'#attributes' => [
@@ -354,12 +357,12 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s
@@ -366,12 +369,12 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s
// link, and is only visible when the move block dialog is open.
'section_label' => [
'#markup' => $this->t('<span class="layout-builder__section-label" aria-hidden="true">@section</span>', ['@section' => $section_label]),
......@@ -136,7 +136,7 @@ index 451927e540..8234a476ab 100644
'#url' => Url::fromRoute('layout_builder.configure_section', [
'section_storage_type' => $storage_type,
'section_storage' => $storage_id,
@@ -379,4 +382,21 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s
@@ -391,4 +394,21 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s
];
}
......@@ -159,7 +159,7 @@ index 451927e540..8234a476ab 100644
+
}
diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module b/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module
index fa027a6b01..443bbcfdfa 100644
index cd6070f53ff33d4f20ef609513ff335c57b63c60..8b6b00419be68eb7d48072f6e0d223f25f9c400c 100644
--- a/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module
+++ b/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module
@@ -13,6 +13,7 @@
......@@ -170,10 +170,11 @@ index fa027a6b01..443bbcfdfa 100644
/**
* Implements hook_plugin_filter_TYPE__CONSUMER_alter().
@@ -177,6 +178,27 @@ function layout_builder_test_module_implements_alter(&$implementations, $hook) {
@@ -131,3 +132,24 @@ function layout_builder_test_module_implements_alter(&$implementations, $hook) {
] + $implementations;
}
}
+
+/**
+ * Implements hook_layout_alter().
+ */
......@@ -194,16 +195,177 @@ index fa027a6b01..443bbcfdfa 100644
+ $variables['content']['main']['custom_element']['#markup'] = $variables['settings']['custom_element'];
+ }
+}
diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutBuilderTestCustomFormPlugin.php b/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutBuilderTestCustomFormPlugin.php
new file mode 100644
index 0000000000000000000000000000000000000000..059a3eb4d8847695d1cbc02fee806c72b9cf94d6
--- /dev/null
+++ b/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutBuilderTestCustomFormPlugin.php
@@ -0,0 +1,23 @@
+<?php
+
/**
* Implements hook_theme().
*/
+namespace Drupal\layout_builder_test\Plugin\Layout;
+
+use Drupal\Core\Layout\LayoutDefault;
+
+/**
+ * @Layout(
+ * id = "layout_builder_test_custom_form_plugin",
+ * label = @Translation("Layout Builder Test Custom Form Plugin"),
+ * regions = {
+ * "main" = {
+ * "label" = @Translation("Main Region")
+ * }
+ * },
+ * forms = {
+ * "configure" = "Drupal\layout_builder_test\PluginForm\CustomLayoutForm",
+ * },
+ * )
+ */
+class LayoutBuilderTestCustomFormPlugin extends LayoutDefault {
+
+}
diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutBuilderTestNoFormPlugin.php b/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutBuilderTestNoFormPlugin.php
new file mode 100644
index 0000000000000000000000000000000000000000..4cef17f51f56591ab331a465274c6fc8e241adc3
--- /dev/null
+++ b/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutBuilderTestNoFormPlugin.php
@@ -0,0 +1,75 @@
+<?php
+
+namespace Drupal\layout_builder_test\Plugin\Layout;
+
+use Drupal\Component\Utility\NestedArray;
+use Drupal\Core\Layout\LayoutInterface;
+use Drupal\Core\Plugin\PluginBase;
+use Drupal\Core\Plugin\PluginWithFormsTrait;
+
+/**
+ * Provides a plugin that does not extend \Drupal\Core\Layout\LayoutDefault.
+ *
+ * @Layout(
+ * id = "layout_builder_test_no_form_plugin",
+ * label = @Translation("Layout Builder Test No Form Plugin"),
+ * regions = {
+ * "main" = {
+ * "label" = @Translation("Main Region")
+ * }
+ * },
+ * )
+ */
+class LayoutBuilderTestNoFormPlugin extends PluginBase implements LayoutInterface {
+
+ use PluginWithFormsTrait;
+
+ /**
+ * {@inheritdoc}
+ */
+ public function build(array $regions) {
+ $build = $regions;
+ $build['#settings'] = $this->getConfiguration();
+ $build['#layout'] = $this->pluginDefinition;
+ $build['#theme'] = $this->pluginDefinition->getThemeHook();
+ return $build;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getConfiguration() {
+ return $this->configuration;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setConfiguration(array $configuration) {
+ $this->configuration = NestedArray::mergeDeep($this->defaultConfiguration(), $configuration);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function defaultConfiguration() {
+ return [
+ 'label' => '',
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function calculateDependencies() {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormClass($operation) {
+ return $this->getPluginDefinition()->get('forms')[$operation] ?? NULL;
+ }
+
+}
diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/src/PluginForm/CustomLayoutForm.php b/core/modules/layout_builder/tests/modules/layout_builder_test/src/PluginForm/CustomLayoutForm.php
new file mode 100644
index 0000000000000000000000000000000000000000..8499f8bde1faa443b4d8220f50599d92c43291c2
--- /dev/null
+++ b/core/modules/layout_builder/tests/modules/layout_builder_test/src/PluginForm/CustomLayoutForm.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Drupal\layout_builder_test\PluginForm;
+
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Plugin\PluginFormBase;
+use Drupal\Core\Plugin\PluginFormInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+
+/**
+ * Provides a custom form for a layout plugin.
+ */
+class CustomLayoutForm extends PluginFormBase {
+
+ use StringTranslationTrait;
+
+ /**
+ * The plugin.
+ *
+ * @var \Drupal\Core\Layout\LayoutInterface
+ */
+ protected $plugin;
+
+ /**
+ * {@inheritdoc}
+ */
+ public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
+ $form = $this->plugin instanceof PluginFormInterface ? $this->plugin->buildConfigurationForm($form, $form_state) : [];
+ $form['custom_element'] = [
+ '#title' => $this->t('Custom element'),
+ '#type' => 'textfield',
+ '#default_value' => $this->plugin->getConfiguration()['custom_element'] ?? '',
+ ];
+ return $form;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
+ if ($this->plugin instanceof PluginFormInterface) {
+ $this->plugin->submitConfigurationForm($form, $form_state);
+ }
+ $configuration = $this->plugin->getConfiguration();
+ $configuration['custom_element'] = $form_state->getValue('custom_element');
+ $this->plugin->setConfiguration($configuration);
+ }
+
+}
diff --git a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php
index 631159a8b3..24f0ff05e7 100644
index f135ac4cb17ca6155dde107c2a04205677e82a5d..ec692e9b45cd777fdc324a366aaf7a89f6614a68 100644
--- a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php
+++ b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php
@@ -458,6 +458,46 @@ public function testPreviewAwareTemplates() {
$assert_session->pageTextNotContains('This is a preview, indeed');
@@ -963,6 +963,46 @@ public function testLayoutBuilderChooseBlocksAlter() {
$assert_session->linkExists('Changed');
}
+ /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment