From 277cf4a8bb8f22fccf3d61e464c700ae84bc2b86 Mon Sep 17 00:00:00 2001
From: Dave Long <dave@longwaveconsulting.com>
Date: Wed, 13 Mar 2024 12:12:28 +0000
Subject: [PATCH] Issue #2985362 by DanielVeza, tim.plunkett, mstrelan,
 quietone, kim.pepper, acbramley: Create an interface to share the definition
 of the overridable methods on DefaultsSectionStorageInterface and
 LayoutEntityDisplayInterface

(cherry picked from commit a99e0b5763a54244712e854a83782d8d2e3b89e4)
---
 .../src/DefaultsSectionStorageInterface.php   | 24 +---------------
 .../Entity/LayoutEntityDisplayInterface.php   | 25 ++---------------
 .../src/LayoutBuilderOverridableInterface.php | 28 +++++++++++++++++++
 3 files changed, 31 insertions(+), 46 deletions(-)
 create mode 100644 core/modules/layout_builder/src/LayoutBuilderOverridableInterface.php

diff --git a/core/modules/layout_builder/src/DefaultsSectionStorageInterface.php b/core/modules/layout_builder/src/DefaultsSectionStorageInterface.php
index a21005a02e21..4fdb7393fe9e 100644
--- a/core/modules/layout_builder/src/DefaultsSectionStorageInterface.php
+++ b/core/modules/layout_builder/src/DefaultsSectionStorageInterface.php
@@ -6,27 +6,5 @@
 
 /**
  * Defines an interface for an object that stores layout sections for defaults.
- *
- * @todo Refactor this interface in https://www.drupal.org/node/2985362.
  */
-interface DefaultsSectionStorageInterface extends SectionStorageInterface, ThirdPartySettingsInterface, LayoutBuilderEnabledInterface {
-
-  /**
-   * Determines if the defaults allow custom overrides.
-   *
-   * @return bool
-   *   TRUE if custom overrides are allowed, FALSE otherwise.
-   */
-  public function isOverridable();
-
-  /**
-   * Sets the defaults to allow or disallow overrides.
-   *
-   * @param bool $overridable
-   *   TRUE if the display should allow overrides, FALSE otherwise.
-   *
-   * @return $this
-   */
-  public function setOverridable($overridable = TRUE);
-
-}
+interface DefaultsSectionStorageInterface extends SectionStorageInterface, ThirdPartySettingsInterface, LayoutBuilderEnabledInterface, LayoutBuilderOverridableInterface {}
diff --git a/core/modules/layout_builder/src/Entity/LayoutEntityDisplayInterface.php b/core/modules/layout_builder/src/Entity/LayoutEntityDisplayInterface.php
index 0122c39955b4..c172c23db791 100644
--- a/core/modules/layout_builder/src/Entity/LayoutEntityDisplayInterface.php
+++ b/core/modules/layout_builder/src/Entity/LayoutEntityDisplayInterface.php
@@ -5,30 +5,9 @@
 use Drupal\Core\Entity\Display\EntityDisplayInterface;
 use Drupal\layout_builder\LayoutBuilderEnabledInterface;
 use Drupal\layout_builder\SectionListInterface;
+use Drupal\layout_builder\LayoutBuilderOverridableInterface;
 
 /**
  * Provides an interface for entity displays that have layout.
- *
- * @todo Refactor this interface in https://www.drupal.org/node/2985362.
  */
-interface LayoutEntityDisplayInterface extends EntityDisplayInterface, SectionListInterface, LayoutBuilderEnabledInterface {
-
-  /**
-   * Determines if the display allows custom overrides.
-   *
-   * @return bool
-   *   TRUE if custom overrides are allowed, FALSE otherwise.
-   */
-  public function isOverridable();
-
-  /**
-   * Sets the display to allow or disallow overrides.
-   *
-   * @param bool $overridable
-   *   TRUE if the display should allow overrides, FALSE otherwise.
-   *
-   * @return $this
-   */
-  public function setOverridable($overridable = TRUE);
-
-}
+interface LayoutEntityDisplayInterface extends EntityDisplayInterface, SectionListInterface, LayoutBuilderEnabledInterface, LayoutBuilderOverridableInterface {}
diff --git a/core/modules/layout_builder/src/LayoutBuilderOverridableInterface.php b/core/modules/layout_builder/src/LayoutBuilderOverridableInterface.php
new file mode 100644
index 000000000000..d3981984fd49
--- /dev/null
+++ b/core/modules/layout_builder/src/LayoutBuilderOverridableInterface.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Drupal\layout_builder;
+
+/**
+ * Provides an interface for displays that could be overridable.
+ */
+interface LayoutBuilderOverridableInterface {
+
+  /**
+   * Determines if the display allows custom overrides.
+   *
+   * @return bool
+   *   TRUE if custom overrides are allowed, FALSE otherwise.
+   */
+  public function isOverridable();
+
+  /**
+   * Sets the display to allow or disallow overrides.
+   *
+   * @param bool $overridable
+   *   TRUE if the display should allow overrides, FALSE otherwise.
+   *
+   * @return $this
+   */
+  public function setOverridable($overridable = TRUE);
+
+}
-- 
GitLab