Merge branch '2.x' into 3.x

* 2.x:
  [Toolkit][Shadcn] Update CSS file
  [Site] Rework Toolkit recipe rendering system, improve our Markdown converter
  [*CS-Fixer] Ensure "apps/" exists before adding it in Finder
  [Site] Un-hide Toolkit, partially reverts #3224
  [Toolkit] Fix forgotten documentation links, follows #3097
  [Translator] Add `keys_patterns` configuration option to filter dumped translations by key patterns
  [Map] Add `Map::removeAll*()` methods
  Truly leverage PHP-CS-Fixer and Twig-CS-Fixer to Fabbot
This commit is contained in:
Hugo Alliaume
2026-01-01 18:20:59 +01:00
4 changed files with 62 additions and 0 deletions

View File

@@ -8,6 +8,10 @@
- Remove option `title` from `Polygon`, `Polyline`, `Rectangle` and `Circle`, use `infoWindow` instead
- Remove property `rawOptions` from `ux:map:*:before-create` events, use `bridgeOptions` instead.
## 2.32
- Add `Map::removeAllMarkers()`, `Map::removeAllPolygons()`, `Map::removeAllPolylines()`, `Map::removeAllCircles()` and `Map::removeAllRectangles()` methods
## 2.31
- Add `fitBoundsToMarkers` parameter to `ux_map()` Twig function

View File

@@ -292,6 +292,22 @@ If you haven't stored the element instance, you can still remove them by passing
$map->removeCircle('my-circle');
$map->removeRectangle('my-rectangle');
To remove all instances of a certain element, you can use the `Map::removeAll*()` methods::
// Add elements
$map->addMarker($marker = new Marker(/* ... */));
$map->addPolygon($polygon = new Polygon(/* ... */));
$map->addPolyline($polyline = new Polyline(/* ... */));
$map->addCircle($circle = new Circle(/* ... */));
$map->addRectangle($rectangle = new Rectangle(/* ... */));
// And later, remove those elements
$map->removeAllMarkers();
$map->removeAllPolygons();
$map->removeAllPolylines();
$map->removeAllCircles();
$map->removeAllRectangles();
Render a map
------------

View File

@@ -64,6 +64,13 @@ abstract class Elements
return $this;
}
public function removeAll(): static
{
$this->elements->removeAll($this->elements);
return $this;
}
public function toArray(): array
{
foreach ($this->elements as $element) {

View File

@@ -133,6 +133,13 @@ final class Map
return $this;
}
public function removeAllMarkers(): self
{
$this->markers->removeAll();
return $this;
}
public function addPolygon(Polygon $polygon): self
{
$this->polygons->add($polygon);
@@ -147,6 +154,13 @@ final class Map
return $this;
}
public function removeAllPolygons(): self
{
$this->polygons->removeAll();
return $this;
}
public function addPolyline(Polyline $polyline): self
{
$this->polylines->add($polyline);
@@ -161,6 +175,13 @@ final class Map
return $this;
}
public function removeAllPolylines(): self
{
$this->polylines->removeAll();
return $this;
}
public function addCircle(Circle $circle): self
{
$this->circles->add($circle);
@@ -175,6 +196,13 @@ final class Map
return $this;
}
public function removeAllCircles(): self
{
$this->circles->removeAll();
return $this;
}
public function addRectangle(Rectangle $rectangle): self
{
$this->rectangles->add($rectangle);
@@ -189,6 +217,13 @@ final class Map
return $this;
}
public function removeAllRectangles(): self
{
$this->rectangles->removeAll();
return $this;
}
/**
* @param array<string, mixed> $extra Extra data forwarded to the JavaScript side. It can be used in your custom
* Stimulus controller to benefit from greater flexibility and customization.