Example #1
0
 /**
  * Loads global configuration from file and process it.
  * @param  string
  * @param  string
  * @return Nette\Utils\ArrayHash
  */
 public static function loadConfig($file = NULL, $section = NULL)
 {
     if (self::$createdAt) {
         throw new Nette\InvalidStateException('Nette\\Configurator has already been created automatically by Nette\\Environment at ' . self::$createdAt);
     } elseif (!defined('TEMP_DIR')) {
         throw new Nette\InvalidStateException('Nette\\Environment requires constant TEMP_DIR with path to temporary directory.');
     }
     $configurator = new Nette\Configurator();
     $configurator->setDebugMode(!self::isProduction())->setTempDirectory(TEMP_DIR)->addParameters(array('container' => array('class' => 'EnvironmentContainer')));
     if ($file) {
         $configurator->addConfig($file, $section);
     }
     self::$context = $configurator->createContainer();
     self::$createdAt = '?';
     foreach (debug_backtrace(FALSE) as $row) {
         if (isset($row['file']) && $row['file'] !== __FILE__ && is_file($row['file'])) {
             self::$createdAt = "{$row['file']}:{$row['line']}";
             break;
         }
     }
     return self::getConfig();
 }
Example #2
0
 /**
  * Loads global configuration from file and process it.
  * @param  string
  * @param  string
  * @return Nette\ArrayHash
  */
 public static function loadConfig($file = NULL, $section = NULL)
 {
     if (self::$createdAt) {
         throw new Nette\InvalidStateException('Nette\\Config\\Configurator has already been created automatically by Nette\\Environment at ' . self::$createdAt);
     }
     $configurator = new Nette\Config\Configurator();
     $configurator->setProductionMode(self::isProduction())->setTempDirectory(defined('TEMP_DIR') ? TEMP_DIR : '');
     if ($file) {
         $configurator->addConfig($file, $section);
     }
     self::$context = $configurator->createContainer();
     self::$createdAt = '?';
     foreach (debug_backtrace(FALSE) as $row) {
         if (isset($row['file']) && is_file($row['file']) && strpos($row['file'], NETTE_DIR . DIRECTORY_SEPARATOR) !== 0) {
             self::$createdAt = "{$row['file']}:{$row['line']}";
             break;
         }
     }
     return self::getConfig();
 }
Example #3
0
 static function getConfigurator()
 {
     if (self::$configurator === NULL) {
         self::$configurator = new Nette\Config\Configurator();
         if (defined('TEMP_DIR')) {
             self::$configurator->setCacheDirectory(TEMP_DIR);
         }
         self::$createdAt = '?';
         foreach (debug_backtrace(FALSE) as $row) {
             if (isset($row['file']) && is_file($row['file']) && strpos($row['file'], NETTE_DIR . DIRECTORY_SEPARATOR) !== 0) {
                 self::$createdAt = "{$row['file']}:{$row['line']}";
                 break;
             }
         }
     }
     return self::$configurator;
 }