public function loadConfiguration()
{
$this->proxyAutoloaders = $this->targetEntityMappings = $this->configuredConnections = $this->managerConfigs = $this->configuredManagers = $this->postCompileRepositoriesQueue = [];
if (!$this->compiler->getExtensions('Kdyby\\Annotations\\DI\\AnnotationsExtension')) {
throw new Nette\Utils\AssertionException('You should register \'Kdyby\\Annotations\\DI\\AnnotationsExtension\' before \'' . get_class($this) . '\'.', E_USER_NOTICE);
}
$builder = $this->getContainerBuilder();
$config = $this->getConfig();
$builder->parameters[$this->prefix('debug')] = !empty($config['debug']);
if (isset($config['dbname']) || isset($config['driver']) || isset($config['connection'])) {
$config = ['default' => $config];
$defaults = ['debug' => $builder->parameters['debugMode']];
} else {
$defaults = array_intersect_key($config, $this->managerDefaults) + array_intersect_key($config, $this->connectionDefaults) + ['debug' => $builder->parameters['debugMode']];
$config = array_diff_key($config, $defaults);
}
if (empty($config)) {
throw new Kdyby\Doctrine\UnexpectedValueException("Please configure the Doctrine extensions using the section '{$this->name}:' in your config file.");
}
foreach ($config as $name => $emConfig) {
if (!is_array($emConfig) || empty($emConfig['dbname']) && empty($emConfig['driver'])) {
throw new Kdyby\Doctrine\UnexpectedValueException("Please configure the Doctrine extensions using the section '{$this->name}:' in your config file.");
}
$emConfig = Nette\DI\Config\Helpers::merge($emConfig, $defaults);
$this->processEntityManager($name, $emConfig);
}
if ($this->targetEntityMappings) {
if (!$this->isKdybyEventsPresent()) {
throw new Nette\Utils\AssertionException('The option \'targetEntityMappings\' requires \'Kdyby\\Events\\DI\\EventsExtension\'.', E_USER_NOTICE);
}
$listener = $builder->addDefinition($this->prefix('resolveTargetEntityListener'))->setClass('Kdyby\\Doctrine\\Tools\\ResolveTargetEntityListener')->addTag(Kdyby\Events\DI\EventsExtension::SUBSCRIBER_TAG)->setInject(FALSE);
foreach ($this->targetEntityMappings as $originalEntity => $mapping) {
$listener->addSetup('addResolveTargetEntity', [$originalEntity, $mapping['targetEntity'], $mapping]);
}
}
$this->loadConsole();
$builder->addDefinition($this->prefix('registry'))->setClass('Kdyby\\Doctrine\\Registry', [$this->configuredConnections, $this->configuredManagers, $builder->parameters[$this->name]['dbal']['defaultConnection'], $builder->parameters[$this->name]['orm']['defaultEntityManager']]);
}