diff --git a/core/lib/Drupal/Core/Layout/Annotation/Layout.php b/core/lib/Drupal/Core/Layout/Annotation/Layout.php index c516ee6d19..ecab4618d3 100644 --- a/core/lib/Drupal/Core/Layout/Annotation/Layout.php +++ b/core/lib/Drupal/Core/Layout/Annotation/Layout.php @@ -116,7 +116,7 @@ class Layout extends Plugin { * * @var string[][] optional * - * @see \Drupal\Core\Layout\IconGeneratorInterface::generateSvgFromIconMap() + * @see \Drupal\Core\Layout\IconGeneratorInterface::generateFromIconMap() */ public $icon_map; diff --git a/core/lib/Drupal/Core/Layout/IconGenerator.php b/core/lib/Drupal/Core/Layout/IconGenerator.php index a3f8e071a5..3c6f8d37ce 100644 --- a/core/lib/Drupal/Core/Layout/IconGenerator.php +++ b/core/lib/Drupal/Core/Layout/IconGenerator.php @@ -3,20 +3,20 @@ namespace Drupal\Core\Layout; /** - * Generates layout icons from well-formed config. + * Generates layout icons. */ class IconGenerator implements IconGeneratorInterface { /** * {@inheritdoc} */ - public function generateSvgFromIconMap(array $icon_map, $label, $width, $height, $padding, $stroke_width = NULL, $fill = NULL, $stroke = NULL) { + public function generateFromIconMap(array $icon_map, $label, $width, $height, $padding, $stroke_width = NULL, $fill = NULL, $stroke = NULL) { $regions = $this->calculateSvgValues($icon_map, $width, $height, $stroke_width, $padding); - return $this->generateSvg($regions, $label, $width, $height, $stroke_width, $fill, $stroke); + return $this->generate($regions, $label, $width, $height, $stroke_width, $fill, $stroke); } /** - * Generates an SVG. + * Generates a render array representation of an SVG. * * @param mixed[] $regions * An array keyed by region name, with each element containing the 'height', @@ -37,7 +37,7 @@ public function generateSvgFromIconMap(array $icon_map, $label, $width, $height, * @return array * A render array representing a SVG icon. */ - protected function generateSvg(array $regions, $label, $width, $height, $stroke_width = NULL, $fill = NULL, $stroke = NULL) { + protected function generate(array $regions, $label, $width, $height, $stroke_width = NULL, $fill = NULL, $stroke = NULL) { $build = [ '#type' => 'html_tag', '#tag' => 'svg', @@ -92,7 +92,7 @@ protected function generateSvg(array $regions, $label, $width, $height, $stroke_ * @param string[][] $rows * A two-dimensional array representing the visual output of the layout. See * the documentation for the $icon_map parameter of - * \Drupal\Core\Layout\IconGeneratorInterface::generateSvgFromIconMap(). + * \Drupal\Core\Layout\IconGeneratorInterface::generateFromIconMap(). * @param int $width * The width of the generated SVG. * @param int $height diff --git a/core/lib/Drupal/Core/Layout/IconGeneratorInterface.php b/core/lib/Drupal/Core/Layout/IconGeneratorInterface.php index 5571edcb4e..beda10cb21 100644 --- a/core/lib/Drupal/Core/Layout/IconGeneratorInterface.php +++ b/core/lib/Drupal/Core/Layout/IconGeneratorInterface.php @@ -3,12 +3,12 @@ namespace Drupal\Core\Layout; /** - * Provides an interface for generating layout icons from well-formed config. + * Provides an interface for generating layout icons. */ interface IconGeneratorInterface { /** - * Generates an SVG based on an icon map. + * Generates a render array representation of an SVG based on an icon map. * * @param string[][] $icon_map * A two-dimensional array representing the visual output of the layout. @@ -48,6 +48,6 @@ * @return array * A render array representing a SVG icon. */ - public function generateSvgFromIconMap(array $icon_map, $label, $width, $height, $padding, $stroke_width = NULL, $fill = NULL, $stroke = NULL); + public function generateFromIconMap(array $icon_map, $label, $width, $height, $padding, $stroke_width = NULL, $fill = NULL, $stroke = NULL); } diff --git a/core/lib/Drupal/Core/Layout/LayoutDefinition.php b/core/lib/Drupal/Core/Layout/LayoutDefinition.php index a25abda405..4c5864edd2 100644 --- a/core/lib/Drupal/Core/Layout/LayoutDefinition.php +++ b/core/lib/Drupal/Core/Layout/LayoutDefinition.php @@ -90,7 +90,7 @@ class LayoutDefinition extends PluginDefinition implements PluginDefinitionInter * * @var string[][]|null * - * @see \Drupal\Core\Layout\IconGeneratorInterface::generateSvgFromIconMap() + * @see \Drupal\Core\Layout\IconGeneratorInterface::generateFromIconMap() */ protected $icon_map; @@ -440,7 +440,7 @@ public function getIcon($width = 125, $height = 150, $stroke_width = 1, $padding ]; } elseif ($icon_map = $this->getIconMap()) { - $icon = $this->getIconGenerator()->generateSvgFromIconMap($icon_map, $this->getLabel(), $width, $height, $padding, $stroke_width, $fill, $stroke); + $icon = $this->getIconGenerator()->generateFromIconMap($icon_map, $this->getLabel(), $width, $height, $padding, $stroke_width, $fill, $stroke); } return $icon; } diff --git a/core/tests/Drupal/KernelTests/Core/Layout/IconGeneratorTest.php b/core/tests/Drupal/KernelTests/Core/Layout/IconGeneratorTest.php index d4909f2121..c7aa1b8f60 100644 --- a/core/tests/Drupal/KernelTests/Core/Layout/IconGeneratorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Layout/IconGeneratorTest.php @@ -13,25 +13,25 @@ class IconGeneratorTest extends KernelTestBase { /** - * @covers ::generateSvg - * @covers ::generateSvgFromIconMap + * @covers ::generate + * @covers ::generateFromIconMap * @covers ::calculateSvgValues * @covers ::getLength * @covers ::getOffset * - * @dataProvider providerTestGenerateSvgFromIconMap + * @dataProvider providerTestGenerateFromIconMap */ - public function testGenerateSvgFromIconMap($icon_map, $label, $expected, $padding = 4, $stroke_width = 2, $stroke = 'black') { + public function testGenerateFromIconMap($icon_map, $label, $expected, $padding = 4, $stroke_width = 2, $stroke = 'black') { $renderer = $this->container->get('renderer'); $icon_generator = new IconGenerator(); - $build = $icon_generator->generateSvgFromIconMap($icon_map, $label, 250, 300, $padding, $stroke_width, 'lightgray', $stroke); + $build = $icon_generator->generateFromIconMap($icon_map, $label, 250, 300, $padding, $stroke_width, 'lightgray', $stroke); $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($build, $renderer) { return $renderer->render($build); }); $this->assertSame($expected, $output); } - public function providerTestGenerateSvgFromIconMap() { + public function providerTestGenerateFromIconMap() { $data = []; $data['empty'][] = []; $data['empty'][] = 'Empty';