Skip to content

Commit

Permalink
Добавил метод setMap для ручного добавления карт трансформации
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpts committed Feb 27, 2019
1 parent 54a7220 commit 8d47390
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/MapsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@ public function setMapDir(string $entityName, string $dir): void
$this->mapsDirs[$entityName] = $dir;
}

/**
* @param string $entityName
* @param string $mapName
*
* @return array[]
*/
public function getMap(string $entityName, string $mapName = 'dto'): array
{
$map = $this->cache[$entityName][$mapName] ?? null;
if ($map === null) {
$dir = $this->mapsDirs[$entityName];
$rules = require $dir.'/'.$mapName.'.php';
$this->cache[$entityName][$mapName] = $this->normalizer->normalize($rules);
$this->setMap($rules, $entityName, $mapName);
}

return $this->cache[$entityName][$mapName];
}

public function setMap(array $rules, string $entityName, $mapName = 'dto'): void
{
$this->cache[$entityName][$mapName] = $this->normalizer->normalize($rules);
}
}

0 comments on commit 8d47390

Please sign in to comment.