mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2026-01-18 05:15:16 +01:00
Rework element id generation.
This commit is contained in:
@@ -39,13 +39,6 @@ class DefinitionMapper
|
||||
*/
|
||||
private $eventDispatcher;
|
||||
|
||||
/**
|
||||
* Map id of the current built map.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $mapId;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -73,21 +66,11 @@ class DefinitionMapper
|
||||
{
|
||||
$this->builders[$priority][] = $builder;
|
||||
|
||||
ksort($this->builders);
|
||||
krsort($this->builders);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the map id of the current built map.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMapId()
|
||||
{
|
||||
return $this->mapId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a model.
|
||||
*
|
||||
@@ -105,15 +88,15 @@ class DefinitionMapper
|
||||
return $this->mapped[$hash];
|
||||
}
|
||||
|
||||
$this->mapId = $elementId ?: ($model->alias ?: ('map_' . $model->id));
|
||||
|
||||
foreach ($this->builders as $builders) {
|
||||
foreach($builders as $builder) {
|
||||
if ($builder->match($model)) {
|
||||
$definition = $builder->handle($model, $this, $bounds);
|
||||
$definition = $builder->handle($model, $this, $bounds, $elementId);
|
||||
|
||||
$event = new BuildDefinitionEvent($definition, $model, $bounds);
|
||||
$this->eventDispatcher->dispatch($event::NAME, $event);
|
||||
if ($definition) {
|
||||
$event = new BuildDefinitionEvent($definition, $model, $bounds);
|
||||
$this->eventDispatcher->dispatch($event::NAME, $event);
|
||||
}
|
||||
|
||||
$this->mapped[$hash] = $definition;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user