Add more controls.

This commit is contained in:
David Molineus
2015-01-05 14:58:37 +01:00
parent be9060795d
commit c00d08c872
8 changed files with 173 additions and 5 deletions

View File

@@ -43,6 +43,11 @@ class DefinitionMapper
*/
private $mapId;
/**
* @var array
*/
private $mapped = array();
/**
* Construct.
*
@@ -88,6 +93,12 @@ class DefinitionMapper
*/
public function handle(\Model $model, $elementId = null)
{
$hash = $model->getTable() . '.' . $model->{$model->getPk()};
if (isset($this->mapped[$hash])) {
return $this->mapped[$hash];
}
krsort($this->builders);
$this->mapId = $elementId ?: ($model->alias ?: ('map_' . $model->id));
@@ -100,6 +111,8 @@ class DefinitionMapper
$event = new BuildDefinitionEvent($definition, $model);
$this->eventDispatcher->dispatch($event::NAME, $event);
$this->mapped[$hash] = $definition;
return $definition;
}
}