Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Map/src/Icon/UxIconRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
*/
class UxIconRenderer
{
/**
* @var array<string, string>
*/
private array $rendered = [];

public function __construct(
private readonly ?IconRendererInterface $renderer,
) {
Expand All @@ -34,7 +39,9 @@ public function render(string $name, array $attributes = []): string
throw new \LogicException('You cannot use an UX Icon as the "UX Icons" package is not installed. Try running "composer require symfony/ux-icons" to install it.');
}

return $this->renderer->renderIcon($name, [
// Markers of a map overwhelmingly share the same icon, so the same SVG
// was rebuilt once per marker.
return $this->rendered[$name.'|'.serialize($attributes)] ??= $this->renderer->renderIcon($name, [
'xmlns' => 'http://www.w3.org/2000/svg',
...$attributes,
]);
Expand Down
Loading