コード例 #1
0
 /**
  * AImportBundle's constructor.
  *
  * @param BBApplication $application
  */
 public function __construct(BBApplication $application)
 {
     $this->_application = $application;
     $this->_config = new Config($this->_dir);
     foreach ($this->_application->getConfig()->getSection('doctrine') as $key => $db_config) {
         $this->_config->setSection($key, $db_config, true);
     }
     $this->_relations = $this->_config->getSection('relations');
     if (0 == count($this->_relations)) {
         return false;
     }
     $log_filepath = $application->getConfig()->getLoggingConfig();
     $log_filepath = $log_filepath['logfile'];
     if ('/' !== $log_filepath[0] || false === is_dir(dirname($log_filepath))) {
         $log_filepath = $application->getBaseDir() . '/log/import.log';
     } else {
         $log_filepath = dirname($log_filepath) . '/import.log';
     }
     $logger = new \BackBee\Logging\Appender\File(array('logfile' => $log_filepath));
     $this->setPhpConf($this->_config->getSection('php_ini'));
     foreach ($this->_relations as $class => $config) {
         $type = true === isset($config['type']) ? $config['type'] : 'import';
         try {
             $this->{$type . ucfirst($class)}($config);
         } catch (SkippedImportException $exc) {
             echo $exc->getMessage() . "\n";
         } catch (\Exception $e) {
             $logger->write(array('d' => date('Y/m/d H:i:s'), 'p' => '', 'm' => $e->getMessage(), 'u' => ''));
         }
     }
     return true;
 }
コード例 #2
0
ファイル: Configurator.php プロジェクト: gobjila/BackBee
 /**
  * Overrides configuration of bundle from the registry.
  *
  * @param  Config  $config              The Config to be extended.
  * @param  string  $bundleId            The bundle Id.
  * @param  boolean $scopePerContext     If TRUE use context in registry scope.
  * @param  boolean $scopePerEnvironment If TRUE use environment in regsitry scope.
  *
  * @return Configurator
  */
 private function overrideConfigByRegistry(Config $config, $bundleId, $scopePerContext, $scopePerEnvironment)
 {
     $registry = $this->getRegistryConfig($bundleId, $scopePerContext, $scopePerEnvironment);
     if (null !== $registry) {
         $registryConfig = @unserialize($registry->getValue());
         if (is_array($registryConfig)) {
             foreach ($registryConfig as $section => $value) {
                 $config->setSection($section, $value, true);
             }
         }
     }
     return $this;
 }
コード例 #3
0
ファイル: ConfigTest.php プロジェクト: gobjila/BackBee
 /**
  * @covers ::deleteSection
  * @covers ::deleteAllSections
  */
 public function testDeleteSection()
 {
     // init test environment
     $config = new Config($this->test_base_dir);
     $parameters_section_settings = array('foo' => 'bar');
     $config->setSection('parameters', $parameters_section_settings);
     // pre test
     $this->assertTrue($config->getSection('say') !== null);
     $this->assertEquals(array_merge(array('say' => $config->getSection('say')), array('parameters' => $parameters_section_settings)), $config->getAllSections());
     // call action to test
     $config->deleteSection('say');
     // post test
     $this->assertFalse($config->getSection('say') !== null);
     $this->assertEquals(array('parameters' => $parameters_section_settings), $config->getAllSections());
     // second test
     $config->deleteAllSections();
     $this->assertEmpty($config->getAllSections());
 }
コード例 #4
0
ファイル: Configurator.php プロジェクト: nietzcheson/BackBee
 /**
  * @param Config $config
  * @param string $bundleId
  */
 private function overrideConfigByRegistry(Config $config, $bundleId)
 {
     $registry = $this->getRegistryConfig($bundleId);
     if (null !== $registry) {
         $registryConfig = @unserialize($registry->getValue());
         if (is_array($registryConfig)) {
             foreach ($registryConfig as $section => $value) {
                 $config->setSection($section, $value, true);
             }
         }
     }
 }