Rework element id generation.

This commit is contained in:
David Molineus
2015-01-09 13:41:09 +01:00
parent 37851110b0
commit efb36256c7
12 changed files with 128 additions and 88 deletions

View File

@@ -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;