Пример #1
0
 /**
  * Load and override services into container; the load order is from the most global to the most specific
  * depends on context and environment.
  */
 private function loadApplicationServices()
 {
     // setting default services
     $this->container->set('bbapp', $this->application);
     $this->container->set('container.builder', $this);
     $services_directory = $this->application->getBBDir() . '/Config/services';
     foreach (scandir($services_directory) as $file) {
         if (1 === preg_match('#(\\w+)\\.(yml|xml)$#', $file, $matches)) {
             if ('yml' === $matches[2]) {
                 ServiceLoader::loadServicesFromYamlFile($this->container, $services_directory, $matches[1]);
             } else {
                 ServiceLoader::loadServicesFromXmlFile($this->container, $services_directory, $matches[1]);
             }
         }
     }
     // define in which directory we have to looking for services yml or xml
     $directories = ConfigDirectory::getDirectories(null, $this->repository_directory, $this->context, $this->environment);
     // Loop into every directory where we can potentially found a services.yml or services.xml
     foreach ($directories as $directory) {
         if (true === is_readable($directory . DIRECTORY_SEPARATOR . self::SERVICE_FILENAME . '.yml')) {
             ServiceLoader::loadServicesFromYamlFile($this->container, $directory);
         }
         if (true === is_readable($directory . DIRECTORY_SEPARATOR . self::SERVICE_FILENAME . '.xml')) {
             ServiceLoader::loadServicesFromXmlFile($this->container, $directory);
         }
     }
     $this->loadLoggerDefinition();
 }
Пример #2
0
 /**
  * Do every extend according to application context and envrionment for application's Config.
  *
  * @param Config $config config we want to apply Application Config extend type
  */
 private function doApplicationConfigExtend(Config $config)
 {
     $config_directories = ConfigDirectory::getDirectories(null, $this->baseRepository, $this->context, $this->environment);
     foreach ($config_directories as $directory) {
         if (is_dir($directory)) {
             $config->extend($directory, $this->overrideConfig);
         }
     }
 }