Esempio n. 1
0
 /**
  * Loads bundle services into application's dependency injection container.
  *
  * @param Config        $config
  * @param callable|null $recipe
  */
 private function loadServices(Config $config, callable $recipe = null)
 {
     if (false === $this->runRecipe($config, $recipe)) {
         $directories = BundleConfigDirectory::getDirectories($this->application->getBaseRepository(), $this->application->getContext(), $this->application->getEnvironment(), basename(dirname($config->getBaseDir())));
         array_unshift($directories, $this->getConfigDirByBundleBaseDir(dirname($config->getBaseDir())));
         foreach ($directories as $directory) {
             $filepath = $directory . DIRECTORY_SEPARATOR . 'services.xml';
             if (is_file($filepath) && is_readable($filepath)) {
                 try {
                     ServiceLoader::loadServicesFromXmlFile($this->container, $directory);
                 } catch (\Exception $e) {
                     // nothing to do
                 }
             }
             $filepath = $directory . DIRECTORY_SEPARATOR . 'services.yml';
             if (is_file($filepath) && is_readable($filepath)) {
                 try {
                     ServiceLoader::loadServicesFromYamlFile($this->container, $directory);
                 } catch (\Exception $e) {
                     // nothing to do
                 }
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * @param Config $config
  * @param string $bundleId
  */
 private function overrideConfigByFile(Config $config, $bundleId)
 {
     $directories = BundleConfigDirectory::getDirectories($this->baseRepository, $this->context, $this->environment, $bundleId);
     foreach ($directories as $directory) {
         $config->extend($directory, false);
     }
 }