Provides wrapper methods for symfony's Container.
Inheritance: extends Symfony\Component\DependencyInjection\Container
Example #1
0
 /**
  * Merge parameters for env's.
  */
 public function mergeParameters()
 {
     $this->loader = new YamlFileLoader($this->container, new FileLocator(APPLICATION_PATH . '/configs/'));
     /**
      * Allways load config for env
      */
     $this->loader->load(APPLICATION_PATH . '/configs/parameters/parameters.yml');
     $this->container->setParameter('application_path', APPLICATION_PATH);
     if (APPLICATION_ENV !== 'production') {
         $tempContainer = new ContainerBuilder();
         $tempLoader = new YamlFileLoader($tempContainer, new FileLocator(APPLICATION_PATH . '/configs/'));
         if (file_exists($file = APPLICATION_PATH . '/configs/parameters/parameters_' . APPLICATION_ENV . '.yml')) {
             $tempLoader->load($file);
         }
         $containerParameters = $this->container->getParameterBag()->all();
         $tempContainerParameters = $tempContainer->getParameterBag()->all();
         $parameters = $this->array_merge_recursive_distinct($containerParameters, $tempContainerParameters);
         foreach ($parameters as $key => $value) {
             $this->container->setParameter($key, $value);
         }
     }
     $this->container->setParameter('storage', array(\Zend_Cloud_StorageService_Adapter_FileSystem::LOCAL_DIRECTORY => APPLICATION_PATH . '/..'));
     /**
      * Load all configs from services directory.
      */
     $services = glob(APPLICATION_PATH . '/configs/services/*.yml');
     foreach ($services as $service) {
         $this->loader->load($service);
     }
 }