You are here

public function SvgIconBuilder::build in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php \Drupal\Core\Layout\Icon\SvgIconBuilder::build()

Builds a render array representation of an SVG based on an icon map.

Parameters

string[][] $icon_map: A two-dimensional array representing the visual output of the layout. For the following shape: |------------------------------| | | | 100% | | | |-------|--------------|-------| | | | | | | 50% | 25% | | | | | | 25% |--------------|-------| | | | | | 75% | | | | |------------------------------| The corresponding array would be:

  • ['top']
  • ['first', 'second', 'second', 'third']
  • ['first', 'bottom', 'bottom', 'bottom'].

Return value

array A render array representing a SVG icon.

Overrides IconBuilderInterface::build

File

core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php, line 57

Class

SvgIconBuilder
Builds SVG layout icons.

Namespace

Drupal\Core\Layout\Icon

Code

public function build(array $icon_map) {
  $regions = $this
    ->calculateSvgValues($icon_map, $this->width, $this->height, $this->strokeWidth, $this->padding);
  return $this
    ->buildRenderArray($regions, $this->width, $this->height, $this->strokeWidth);
}