protected final function extendRepositoryMapping()
{
$app = $this->getContainer();
$app['storage'] = $app->share($app->extend('storage', function ($entityManager) use($app) {
foreach ($this->registerRepositoryMappings() as $alias => $map) {
if (Arr::isIndexedArray($map)) {
// Usually caused by [entity, repo] instead of [entity => repo]
throw new \RuntimeException(sprintf('Repository mapping for %s `%s` is not an associative array.', __CLASS__, $alias));
}
$app['storage.repositories'] += $map;
$app['storage.metadata']->setDefaultAlias($app['schema.prefix'] . $alias, key($map));
$entityManager->setRepository(key($map), current($map));
$entityManager->addEntityAlias($alias, key($map));
}
return $entityManager;
}));
}