当前位置: 首页>>代码示例>>PHP>>正文


PHP Environment::getServiceLocator方法代码示例

本文整理汇总了PHP中Nette\Environment::getServiceLocator方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getServiceLocator方法的具体用法?PHP Environment::getServiceLocator怎么用?PHP Environment::getServiceLocator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Environment的用法示例。


在下文中一共展示了Environment::getServiceLocator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _paintBlueScreen

 /**
  * Paint blue screen.
  * @param  \Exception
  * @return void
  * @ignore internal
  */
 public static function _paintBlueScreen(\Exception $exception)
 {
     $internals = array();
     foreach (array('Nette\\Object', 'Nette\\ObjectMixin') as $class) {
         if (class_exists($class, FALSE)) {
             $rc = new \ReflectionClass($class);
             $internals[$rc->getFileName()] = TRUE;
         }
     }
     if (class_exists('Nette\\Environment', FALSE)) {
         $application = Environment::getServiceLocator()->hasService('Nette\\Application\\Application', TRUE) ? Environment::getServiceLocator()->getService('Nette\\Application\\Application') : NULL;
     }
     require __DIR__ . '/templates/bluescreen.phtml';
 }
开发者ID:nella,项目名称:ActiveMapper,代码行数:20,代码来源:Debug.php

示例2: _paintBlueScreen

 /**
  * Paint blue screen.
  * @param  \Exception
  * @return void
  * @ignore internal
  */
 public static function _paintBlueScreen(\Exception $exception)
 {
     if (class_exists('Nette\\Environment', FALSE)) {
         $application = Environment::getServiceLocator()->hasService('Nette\\Application\\Application', TRUE) ? Environment::getServiceLocator()->getService('Nette\\Application\\Application') : NULL;
     }
     require __DIR__ . '/templates/bluescreen.phtml';
 }
开发者ID:vrana,项目名称:ORM-benchmark,代码行数:13,代码来源:Debug.php

示例3: loadConfig

 /**
  * Loads global configuration from file and process it.
  * @param  string|Nette\Config\Config  file name or Config object
  * @return Nette\Config\Config
  */
 public function loadConfig($file)
 {
     $name = Environment::getName();
     if ($file instanceof Nette\Config\Config) {
         $config = $file;
         $file = NULL;
     } else {
         if ($file === NULL) {
             $file = $this->defaultConfigFile;
         }
         $file = Environment::expand($file);
         $config = Nette\Config\Config::fromFile($file, $name);
     }
     // process environment variables
     if ($config->variable instanceof Nette\Config\Config) {
         foreach ($config->variable as $key => $value) {
             Environment::setVariable($key, $value);
         }
     }
     // expand variables
     $iterator = new \RecursiveIteratorIterator($config);
     foreach ($iterator as $key => $value) {
         $tmp = $iterator->getDepth() ? $iterator->getSubIterator($iterator->getDepth() - 1)->current() : $config;
         $tmp[$key] = Environment::expand($value);
     }
     // process services
     $runServices = array();
     $locator = Environment::getServiceLocator();
     if ($config->service instanceof Nette\Config\Config) {
         foreach ($config->service as $key => $value) {
             $key = strtr($key, '-', '\\');
             // limited INI chars
             if (is_string($value)) {
                 $locator->removeService($key);
                 $locator->addService($key, $value);
             } else {
                 if ($value->factory) {
                     $locator->removeService($key);
                     $locator->addService($key, $value->factory, isset($value->singleton) ? $value->singleton : TRUE, (array) $value->option);
                 }
                 if ($value->run) {
                     $runServices[] = $key;
                 }
             }
         }
     }
     // process ini settings
     if (!$config->php) {
         // backcompatibility
         $config->php = $config->set;
         unset($config->set);
     }
     if ($config->php instanceof Nette\Config\Config) {
         if (PATH_SEPARATOR !== ';' && isset($config->php->include_path)) {
             $config->php->include_path = str_replace(';', PATH_SEPARATOR, $config->php->include_path);
         }
         foreach (clone $config->php as $key => $value) {
             // flatten INI dots
             if ($value instanceof Nette\Config\Config) {
                 unset($config->php->{$key});
                 foreach ($value as $k => $v) {
                     $config->php->{"{$key}.{$k}"} = $v;
                 }
             }
         }
         foreach ($config->php as $key => $value) {
             $key = strtr($key, '-', '.');
             // backcompatibility
             if (!is_scalar($value)) {
                 throw new \InvalidStateException("Configuration value for directive '{$key}' is not scalar.");
             }
             if ($key === 'date.timezone') {
                 // PHP bug #47466
                 date_default_timezone_set($value);
             }
             if (function_exists('ini_set')) {
                 ini_set($key, $value);
             } else {
                 switch ($key) {
                     case 'include_path':
                         set_include_path($value);
                         break;
                     case 'iconv.internal_encoding':
                         iconv_set_encoding('internal_encoding', $value);
                         break;
                     case 'mbstring.internal_encoding':
                         mb_internal_encoding($value);
                         break;
                     case 'date.timezone':
                         date_default_timezone_set($value);
                         break;
                     case 'error_reporting':
                         error_reporting($value);
                         break;
                     case 'ignore_user_abort':
//.........这里部分代码省略.........
开发者ID:nella,项目名称:ActiveMapper,代码行数:101,代码来源:Configurator.php

示例4: getServiceLocator

 /**
  * Gets the service locator (experimental).
  * @return Nette\IServiceLocator
  */
 public final function getServiceLocator()
 {
     if ($this->serviceLocator === NULL) {
         $this->serviceLocator = new Nette\ServiceLocator(Environment::getServiceLocator());
         foreach ($this->defaultServices as $name => $service) {
             if (!$this->serviceLocator->hasService($name)) {
                 $this->serviceLocator->addService($name, $service);
             }
         }
     }
     return $this->serviceLocator;
 }
开发者ID:jakubkulhan,项目名称:nette,代码行数:16,代码来源:Application.php


注:本文中的Nette\Environment::getServiceLocator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。