コード例 #1
0
ファイル: Environment.php プロジェクト: newPOPE/screencast
	/**
	 * Get initial instance of context.
	 * @return IContext
	 */
	public static function getContext()
	{
		if (self::$context === NULL) {
			self::$context = self::getConfigurator()->createContext();
		}
		return self::$context;
	}
コード例 #2
0
ファイル: Environment.php プロジェクト: ptacekj/nette-mrdka
 /**
  * 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();
 }
コード例 #3
0
ファイル: Environment.php プロジェクト: kravco/nette
 /**
  * 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();
 }
コード例 #4
0
ファイル: nette.min.php プロジェクト: skapytek/scripts
 static function getContext()
 {
     if (self::$context === NULL) {
         self::$context = self::getConfigurator()->getContainer();
     }
     return self::$context;
 }