diff --git a/core/lib/Drupal/Core/Layout/Annotation/Layout.php b/core/lib/Drupal/Core/Layout/Annotation/Layout.php index d2072c2..725aa43 100644 --- a/core/lib/Drupal/Core/Layout/Annotation/Layout.php +++ b/core/lib/Drupal/Core/Layout/Annotation/Layout.php @@ -112,6 +112,13 @@ class Layout extends Plugin { public $icon; /** + * The icon map. + * + * @var array optional + */ + public $icon_map; + + /** * An associative array of regions in this layout. * * The key of the array is the machine name of the region, and the value is diff --git a/core/lib/Drupal/Core/Layout/LayoutDefinition.php b/core/lib/Drupal/Core/Layout/LayoutDefinition.php index a2be60b..cc452a7 100644 --- a/core/lib/Drupal/Core/Layout/LayoutDefinition.php +++ b/core/lib/Drupal/Core/Layout/LayoutDefinition.php @@ -86,6 +86,15 @@ class LayoutDefinition extends PluginDefinition implements PluginDefinitionInter protected $icon; /** + * An array defining the regions of a layout. + * + * @var array|null + * + * @see \Drupal\Core\Layout\IconGeneratorInterface::generateSvgFromIconMap() + */ + protected $icon_map; + + /** * An associative array of regions in this layout. * * The key of the array is the machine name of the region, and the value is @@ -372,6 +381,31 @@ public function setIconPath($icon) { } /** + * Gets the icon map for this layout definition. + * + * This should not be used if an icon path is specified. See ::getIcon(). + * + * @return array|null + * The icon map, if it exists. + */ + public function getIconMap() { + return $this->icon_map; + } + + /** + * Sets the icon map for this layout definition. + * + * @param array|null $icon_map + * The icon map. + * + * @return $this + */ + public function setIconMap($icon_map) { + $this->icon_map = $icon_map; + return $this; + } + + /** * Builds a render array for an icon representing the layout. * * @param int $width @@ -404,7 +438,7 @@ public function getIcon($width = 250, $height = 300, $stroke_width = 2, $padding '#height' => $height, ]; } - elseif ($icon_map = $this->get('icon_map')) { + elseif ($icon_map = $this->getIconMap()) { $icon = $this->getIconGenerator()->generateSvgFromIconMap($icon_map, $width, $height, $stroke_width, $padding, $fill, $stroke); } return $icon;