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
 /**
  * Returns path to the right directory to dump and save config.yml file.
  *
  * @param string $baseDir config base directory
  *
  * @return string
  */
 private function getConfigDumpRightDirectory($baseDir)
 {
     $configDumpDir = $this->app->getBaseRepository();
     if ($this->persistPerContext && ApplicationInterface::DEFAULT_CONTEXT !== $this->app->getContext()) {
         $configDumpDir .= DIRECTORY_SEPARATOR . $this->app->getContext();
     }
     $configDumpDir .= DIRECTORY_SEPARATOR . 'Config';
     if ($this->persistPerEnvironment && ApplicationInterface::DEFAULT_ENVIRONMENT !== $this->app->getEnvironment()) {
         $configDumpDir .= DIRECTORY_SEPARATOR . $this->app->getEnvironment();
     }
     $key = $this->app->getContainer()->get('bundle.loader')->getBundleIdByBaseDir($baseDir);
     if (null !== $key) {
         $configDumpDir .= DIRECTORY_SEPARATOR . 'bundle' . DIRECTORY_SEPARATOR . $key;
     }
     if (!is_dir($configDumpDir) && false === @mkdir($configDumpDir, 0755, true)) {
         throw new \Exception('Unable to create config dump directory');
     }
     return $configDumpDir;
 }
 /**
  * ContainerBuilder's constructor;.
  *
  * @param BackBee\ApplicationInterface $application the application we want to build a container for
  */
 public function __construct(ApplicationInterface $application)
 {
     $this->application = $application;
     $this->repository_directory = $application->getBaseRepository();
     $this->context = $application->getContext();
     $this->environment = $application->getEnvironment();
 }
Esempio n. 4
0
 /**
  * Configurator's constructor.
  *
  * @param boolean $overrideConfig define if we should override config on extend()
  */
 public function __construct(ApplicationInterface $application, BundleLoader $bundleLoader)
 {
     $this->application = $application;
     $this->bundleLoader = $bundleLoader;
     $this->baseRepository = $application->getBaseRepository();
     $this->context = $application->getContext();
     $this->environment = $application->getEnvironment();
     $this->overrideConfig = $application->isOverridedConfig();
 }