Exemple #1
0
 /**
  * @see BackBee\Config\Persistor\PersistorInterface::persist
  */
 public function persist(Config $config, array $configToPersist)
 {
     if (array_key_exists('override_site', $configToPersist)) {
         $configToPersist = array('override_site' => $configToPersist['override_site']);
     }
     $baseScope = 'BUNDLE_CONFIG.';
     $key = $this->app->getContainer()->get('bundle.loader')->getBundleIdByBaseDir($config->getBaseDir());
     if (null === $key) {
         $key = $application;
         $baseScope = 'APPLICATION_CONFIG.';
     }
     $scope = $baseScope . $this->app->getContext() . '.' . $this->app->getEnvironment();
     $registry = $this->app->getEntityManager()->getRepository('BackBee\\Bundle\\Registry')->findOneBy(array('key' => $key, 'scope' => $scope));
     if (null === $registry) {
         $registry = new RegistryEntity();
         $registry->setKey($key);
         $registry->setScope($scope);
         $this->app->getEntityManager()->persist($registry);
     }
     $registry->setValue(serialize($configToPersist));
     $success = true;
     try {
         $this->app->getEntityManager()->flush($registry);
     } catch (\Exception $e) {
         $success = false;
     }
     return $success;
 }
Exemple #2
0
 /**
  * test the Config constructor.
  *
  * @covers ::extend
  * @covers ::loadFromBaseDir
  * @covers ::getYmlFiles
  * @covers ::loadFromFile
  * @covers ::sectionHasKey
  * @covers ::getSection
  * @covers ::getBaseDir
  */
 public function testConstruct()
 {
     $config = new Config($this->test_base_dir);
     $this->assertEquals($this->test_base_dir, $config->getBaseDir());
     $this->assertTrue($config->sectionHasKey('say', 'hello'));
     $this->assertFalse($config->sectionHasKey('say', 'hi'));
     $this->assertEquals($config->getSection('say'), array('hello' => 'world', 'bonjour' => 'monde', 'hola' => 'mundo'));
 }
Exemple #3
0
 /**
  * @see BackBee\Config\Persistor\PersistorInterface::persist
  */
 public function persist(Config $config, array $configToPersist)
 {
     try {
         $success = file_put_contents($this->getConfigDumpRightDirectory($config->getBaseDir()) . DIRECTORY_SEPARATOR . 'config.yml', Yaml::dump($configToPersist));
     } catch (\Exception $e) {
         $success = false;
     }
     return false !== $success;
 }