diff --git a/core/modules/layout/lib/Drupal/layout/Config/BoundDisplayInterface.php b/core/modules/layout/lib/Drupal/layout/Config/BoundDisplayInterface.php index 1af540c..beceff2 100644 --- a/core/modules/layout/lib/Drupal/layout/Config/BoundDisplayInterface.php +++ b/core/modules/layout/lib/Drupal/layout/Config/BoundDisplayInterface.php @@ -8,6 +8,15 @@ use Drupal\layout\Plugin\LayoutInterface; +/** + * Interface for a Display object that is coupled to a specific layout plugin. + * + * This display contains references both to block instances and a specific + * layout plugin. The blocks are assigned to the regions declared by that + * layout. Bound Displays are used to serve real pages at request time. + * + * @see \Drupal\layout\Config\DisplayInterface + */ interface BoundDisplayInterface extends DisplayInterface { /** @@ -52,10 +61,14 @@ public function getAllSortedBlocks(); public function getLayoutInstance(); /** - * Adjusts this display's block information in response to a changed layout. + * Adjusts this display's block placement to work with the provided layout. + * + * Essentially a shortcut that calls DisplayInterface::mapBlocksToLayout(), + * saves the result in the appropriate object property, and finally calls + * BoundDisplayInterface::setLayout(). * * @param \Drupal\layout\Plugin\LayoutInterface $layout - * The new layout. + * The new layout to which blocks should be remapped. * * @see \Drupal\layout\Config\DisplayInterface::mapBlocksToLayout() */ diff --git a/core/modules/layout/lib/Drupal/layout/Config/DisplayBase.php b/core/modules/layout/lib/Drupal/layout/Config/DisplayBase.php index 95c07bb..ec11520 100644 --- a/core/modules/layout/lib/Drupal/layout/Config/DisplayBase.php +++ b/core/modules/layout/lib/Drupal/layout/Config/DisplayBase.php @@ -127,4 +127,17 @@ public function mapBlocksToLayout(LayoutInterface $layout) { return $remapped_config; } + + /** + * Implements DisplayInterface::getAllRegionTypes(). + * + * @return array + */ + public function getAllRegionTypes() { + $types = array(); + foreach ($this->blockInfo as $info) { + $types[$info['region-type']] = TRUE; + } + return array_keys($types); + } } diff --git a/core/modules/layout/lib/Drupal/layout/Config/DisplayInterface.php b/core/modules/layout/lib/Drupal/layout/Config/DisplayInterface.php index 1337077..06e1635 100644 --- a/core/modules/layout/lib/Drupal/layout/Config/DisplayInterface.php +++ b/core/modules/layout/lib/Drupal/layout/Config/DisplayInterface.php @@ -8,6 +8,19 @@ use Drupal\layout\Plugin\LayoutInterface; +/** + * Interface describing a Display configuration object. + * + * Displays are configuration that describe the placement of block instances + * in regions, as well as certain ways (for example, caching and visibility) of + * those block instances within those regions. + * + * Drupal ships with two major families of Display objects: + * + * @see \Drupal\layout\Config\BoundDisplayInterface + * @see \Drupal\layout\Config\UnboundDisplayInterface + * + */ interface DisplayInterface { /** @@ -36,4 +49,13 @@ public function getAllBlockInfo(); * is returned by DisplayInterface::getAllBlockInfo(). */ public function mapBlocksToLayout(LayoutInterface $layout); + + /** + * Returns the names of all region types to which blocks are assigned. + * + * @return array + * An indexed array of unique region type names, or an empty array if no + * region types were assigned. + */ + public function getAllRegionTypes(); } diff --git a/core/modules/layout/lib/Drupal/layout/Config/UnboundDisplayInterface.php b/core/modules/layout/lib/Drupal/layout/Config/UnboundDisplayInterface.php index d709db1..7139397 100644 --- a/core/modules/layout/lib/Drupal/layout/Config/UnboundDisplayInterface.php +++ b/core/modules/layout/lib/Drupal/layout/Config/UnboundDisplayInterface.php @@ -8,6 +8,18 @@ use Drupal\layout\Plugin\LayoutInterface; +/** + * Interface for a Display that is not coupled with any layout plugin. + * + * Unbound Displays contain references to blocks, but not to any particular + * layout plugin. Their primary use case is to express a set of relative block + * placements without necessitating any particular layout be present. This + * allows upstream (module and distribution) developers to express a visual + * composition of blocks without knowing anything about the layout plugins a + * particular site has available. + * + * @see \Drupal\layout\Config\DisplayInterface + */ interface UnboundDisplayInterface extends DisplayInterface { /** * Bind this UnboundDisplay to a particular display. diff --git a/core/modules/layout/lib/Drupal/layout/Plugin/Core/Entity/Display.php b/core/modules/layout/lib/Drupal/layout/Plugin/Core/Entity/Display.php index 3b5a004..7a38ed2 100644 --- a/core/modules/layout/lib/Drupal/layout/Plugin/Core/Entity/Display.php +++ b/core/modules/layout/lib/Drupal/layout/Plugin/Core/Entity/Display.php @@ -130,10 +130,7 @@ protected function sortBlocks() { } /** - * Perform block remapping per mapBlocksToLayout(), but mutate this object - * with the remapping results instead of returning them. - * - * @see \Drupal\layout\Config\DisplayBase::mapBlocksToLayout() + * Implements BoundDisplayInterface::remapToLayout(). * * @param \Drupal\layout\Plugin\LayoutInterface $layout */ diff --git a/core/modules/layout/lib/Drupal/layout/Tests/DisplayInternalLogicTest.php b/core/modules/layout/lib/Drupal/layout/Tests/DisplayInternalLogicTest.php index 47ca634..07a77bf 100644 --- a/core/modules/layout/lib/Drupal/layout/Tests/DisplayInternalLogicTest.php +++ b/core/modules/layout/lib/Drupal/layout/Tests/DisplayInternalLogicTest.php @@ -13,7 +13,6 @@ /** * Tests the API and internal logic offered by Displays. - * */ class DisplayInternalLogicTest extends WebTestBase {