• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP core\Environment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中lithium\core\Environment的典型用法代码示例。如果您正苦于以下问题:PHP Environment类的具体用法?PHP Environment怎么用?PHP Environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: config

 public static function config($name = null)
 {
     if (empty(self::$_config)) {
         $config = Libraries::get('li3_varnish');
         $env = Environment::get();
         if (isset($config[$env])) {
             $config += $config[$env];
             unset($config[$env]);
         }
         foreach ($config as $k => $v) {
             if (isset(self::$_defaults[$k]) && is_array(self::$_defaults[$k])) {
                 $config[$k] += self::$_defaults[$k];
             }
         }
         self::$_config = $config + self::$_defaults;
     }
     if (isset($name)) {
         if (isset(self::$_config[$name])) {
             return self::$_config[$name];
         } else {
             return null;
         }
     }
     return self::$_config;
 }
开发者ID:brandonwestcott,项目名称:li3_varnish,代码行数:25,代码来源:Varnish.php


示例2: getInstance

 /**
  * Return an instance of the Mandrill class.
  *
  * @return Mandrill Instance.
  */
 public static function getInstance()
 {
     // Detect when the PID of the current process has changed (from a fork, etc)
     // and force a reconnect to redis.
     $pid = getmypid();
     if (self::$pid !== $pid) {
         self::$mandrill = null;
         self::$pid = $pid;
     }
     if (!is_null(self::$mandrill)) {
         return self::$mandrill;
     }
     foreach (array_keys(self::$config) as $param) {
         if (Environment::get('mandrill.' . $param)) {
             self::$config[$param] = Environment::get('mandrill.' . $param);
         }
     }
     if (!self::$config['apikey']) {
         throw new Exception('missing Mandrill Configuration', 500);
     }
     try {
         self::$mandrill = new Mandrill(self::$config['apikey']);
     } catch (Exception $e) {
         return null;
     }
     return self::$mandrill;
 }
开发者ID:robert-christopher,项目名称:li3_mandrill,代码行数:32,代码来源:Li3Mandrill.php


示例3: getkycinfo

 public function getkycinfo()
 {
     $email = strtolower($this->request->query['email']);
     $kycid = $this->request->query['kycid'];
     if (substr(Environment::get('locale'), 0, 2) == "en") {
         $locale = "en";
     } else {
         $locale = Environment::get('locale');
     }
     if ($email == "" || $kycid == "") {
         return $this->render(array('json' => array('success' => 0)));
     }
     $document = Documents::find('first', array('conditions' => array('email' => $email, 'email_code' => $kycid)));
     $encrypt = $document['hash'];
     //		print_r($function->decrypt($encrypt,CONNECTION_DB_KYC));
     if (count($document) == 1) {
         if ($emails['Verify']['Score'] >= 80) {
             return $this->render(array('json' => array('success' => 0, 'reason' => 'Aleredy KYC complete')));
         } else {
             return $this->render(array('json' => array('success' => 1, 'id' => $encrypt, 'locale' => $locale)));
         }
     } else {
         return $this->render(array('json' => array('success' => 0)));
     }
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:25,代码来源:ProcessController.php


示例4: _config

 protected static function _config($model, Behavior $behavior, array $config, array $defaults)
 {
     $config += $defaults;
     if (!$config['locale']) {
         $config['locale'] = Environment::get('locale');
     }
     if (!$config['locales']) {
         $config['locales'] = array_keys(Environment::get('locales'));
     }
     if (!$config['strategy']) {
         $connection = get_class($model::connection());
         $config['strategy'] = $connection::enabled('arrays') ? 'nested' : 'inline';
     }
     if ($config['strategy'] === 'inline') {
         foreach ($config['fields'] as $field) {
             foreach ($config['locales'] as $locale) {
                 if ($locale === $config['locale']) {
                     continue;
                 }
                 if (!$model::hasField($field = static::_composeField($field, $locale))) {
                     throw new Exception("Model `{$model}` is missing translation field `{$field}`");
                 }
             }
         }
     }
     return $config;
 }
开发者ID:davidpersson,项目名称:li3_translate,代码行数:27,代码来源:Translatable.php


示例5: __construct

 public function __construct($options = array())
 {
     $this->_library = Libraries::get('li3_hierarchy');
     $this->_cacheDir = $this->_library['path'] . '/resources/tmp/cache';
     $defaults['cache'] = Environment::get() == 'production' ? true : false;
     $this->_options = $this->_library + $defaults;
     $this->_cache = $this->_options['cache'];
 }
开发者ID:joseym,项目名称:li3_hierarchy,代码行数:8,代码来源:Cache.php


示例6: __construct

 /**
  * Constructor for this adapter - sets relevant default configurations for Twig to be used
  * when instantiating a new Twig_Environment and Twig_Loader_Filesystem.
  *
  * @param array $config Optional configuration directives.
  *        Please see http://www.twig-project.org/book/03-Twig-for-Developers for all
  *        available configuration keys and their description.
  *        There are 4 settings that is set
  *        - `cache`: Path to /resources/tmp/cache/templates/ where compiled templates will be stored
  *        - `auto_reload`: If Environment is not production, templates will be reloaded once edited
  *        - `base_template_class`: Overriden to the Template adapter, be carefull with changing this
  *        - `autoescape`: Set to false because the way we inject content is with full html that should not be escaped
  * @return void
  */
 public function __construct(array $config = array())
 {
     /**
      * TODO Change hardcoded LITHIUM_APP_PATH to be dynamic
      */
     $defaults = array('cache' => LITHIUM_APP_PATH . '/resources/tmp/cache/templates', 'auto_reload' => !Environment::is('production'), 'base_template_class' => 'li3_twig\\template\\view\\adapter\\Template', 'autoescape' => false);
     parent::__construct($config + $defaults);
 }
开发者ID:nervetattoo,项目名称:li3_twig,代码行数:22,代码来源:Twig.php


示例7: testEnvironmentalDefaults

 public function testEnvironmentalDefaults()
 {
     $artist = Artists::create(['ja.name' => 'Richard Japper', 'ja.profile' => 'Dreaded Rasta Nihon', 'en.name' => 'Richard', 'en.profile' => 'Dreaded Rasta', 'something_else' => 'Something']);
     Environment::set('test', ['locales' => ['en' => 'English', 'es' => 'Espanol']]);
     $artist->_actsAs = ['Translatable' => ['default' => 'ja', 'fields' => ['name', 'profile']]];
     $this->assertTrue($artist->save());
     $artist = Artists::first();
 }
开发者ID:davidpersson,项目名称:li3_translate,代码行数:8,代码来源:TranslatableTest.php


示例8: _init

 protected function _init()
 {
     parent::_init();
     Environment::set($this->env);
     if (file_exists($this->_config['routes'])) {
         return require $this->_config['routes'];
     }
     $this->error("The routes file for this library doesn't exist or can't be found.");
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:9,代码来源:Route.php


示例9: config

 /**
  * Configures this helper
  */
 public static function config($config = array())
 {
     $defaults = array('optimize' => Environment::get() == 'production', 'debug' => Environment::get() == 'development', 'stylesPath' => LITHIUM_APP_PATH . DIRECTORY_SEPARATOR . 'webroot' . DIRECTORY_SEPARATOR . 'css', 'scriptsPath' => LITHIUM_APP_PATH . DIRECTORY_SEPARATOR . 'webroot' . DIRECTORY_SEPARATOR . 'js', 'filters' => array());
     $config += $defaults;
     // Merge config
     static::$config = array_merge(static::$config, $config);
     // Configure filters
     static::registerFilters($config['filters']);
 }
开发者ID:nateabele,项目名称:li3_assetic,代码行数:12,代码来源:Assetic.php


示例10: shouldRun

 /**
  *
  * Determines if we should run any `newrelic_` methods.
  *
  * If the configuration for the plugin `shouldRun` does not exist, set
  * a generic one.
  *
  * @return bool
  */
 public static function shouldRun()
 {
     if (!is_callable(Libraries::get('li3_newrelic', 'shouldRun'))) {
         $config = Libraries::get('li3_newrelic');
         $config['shouldRun'] = function () {
             return Environment::is('production') && extension_loaded('newrelic');
         };
         Libraries::add('li3_newrelic', $config);
     }
     return Libraries::get('li3_newrelic', 'shouldRun')->__invoke();
 }
开发者ID:mdx-dev,项目名称:li3_newrelic,代码行数:20,代码来源:Newrelic.php


示例11: run

 /**
  * Auto run the help command.
  *
  * @param string $command Name of the command to return help about.
  * @return void
  */
 public function run($command = null)
 {
     $message = 'Lithium console started in the ' . Environment::get() . ' environment.';
     $message .= ' Use the --env=environment key to alter this.';
     $this->out($message);
     if (!$command) {
         $this->_renderCommands();
         return true;
     }
     if (!preg_match('/\\\\/', $command)) {
         $command = ucwords($command);
     }
     if (!($class = Libraries::locate('command', $command))) {
         $this->error("Command `{$command}` not found");
         return false;
     }
     $command = Inflector::classify($command);
     if (strpos($command, '\\') !== false) {
         $command = join('', array_slice(explode("\\", $command), -1));
     }
     $command = strtolower(Inflector::slug($command));
     $run = null;
     $methods = $this->_methods($class);
     $properties = $this->_properties($class);
     $info = Inspector::info($class);
     $this->out('USAGE', 'heading');
     if (isset($methods['run'])) {
         $run = $methods['run'];
         unset($methods['run']);
         $this->_renderUsage($command, $run, $properties);
     }
     foreach ($methods as $method) {
         $this->_renderUsage($command, $method);
     }
     if (!empty($info['description'])) {
         $this->nl();
         $this->_renderDescription($info);
         $this->nl();
     }
     if ($properties || $methods) {
         $this->out('OPTIONS', 'heading');
     }
     if ($run) {
         $this->_render($run['args']);
     }
     if ($methods) {
         $this->_render($methods);
     }
     if ($properties) {
         $this->_render($properties);
     }
     return true;
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:59,代码来源:Help.php


示例12: createEntityManager

 /**
  * Create an entity manager
  *
  * @param array $params Parameters
  * @return object Entity manager
  * @filter
  */
 protected function createEntityManager()
 {
     $configuration = Setup::createAnnotationMetadataConfiguration([$this->_config['models']], Environment::is('development'), $this->_config['proxies'], isset($this->_config['cache']) ? call_user_func($this->_config['cache']) : null);
     $configuration->setProxyNamespace($this->_config['proxyNamespace']);
     $eventManager = new EventManager();
     $eventManager->addEventListener([Events::postLoad, Events::prePersist, Events::preUpdate], $this);
     $connection = $this->connectionSettings;
     $params = compact('connection', 'configuration', 'eventManager');
     return $this->_filter(__METHOD__, $params, function ($self, $params) {
         return EntityManager::create($params['connection'], $params['configuration'], $params['eventManager']);
     });
 }
开发者ID:mariano,项目名称:li3_doctrine2,代码行数:19,代码来源:Doctrine.php


示例13: _verify

 protected function _verify($request)
 {
     $config = Environment::get('service.recaptcha');
     $url = 'https://www.google.com/recaptcha/api/siteverify';
     $url .= '?secret=' . $config['secretKey'];
     $url .= '&response=' . $this->request->data['token'];
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $result = json_decode(curl_exec($ch), true);
     curl_close($ch);
     return $result['success'] === true;
 }
开发者ID:Robert-Christopher,项目名称:site,代码行数:12,代码来源:PagesController.php


示例14: _init

 public function _init()
 {
     parent::_init();
     $this->_config = Libraries::get('li3_frontender');
     $defaults = array('compress' => false, 'assets_root' => LITHIUM_APP_PATH . "/webroot", 'production' => Environment::get() == 'production', 'locations' => array('node' => '/usr/bin/node', 'coffee' => '/usr/bin/coffee'));
     $this->_config += $defaults;
     $this->_production = $this->_config['production'];
     // remove extra slash if it was included in the library config
     $this->_config['assets_root'] = substr($this->_config['assets_root'], -1) == "/" ? substr($this->_config['assets_root'], 0, -1) : $this->_config['assets_root'];
     $this->_paths['styles'] = $this->_config['assets_root'] . "/css/";
     $this->_paths['scripts'] = $this->_config['assets_root'] . "/js/";
 }
开发者ID:joseym,项目名称:li3_frontender,代码行数:12,代码来源:Assets.php


示例15: sendLoggedQueries

 public function sendLoggedQueries()
 {
     if ($this->key) {
         KM::$key = $this->key;
     }
     if ($this->logdir) {
         KM::$log_dir = $this->logdir;
     }
     $this->header('Kissmetrics');
     $this->out(" - Using Environment: \t" . Environment::get());
     $this->out(" - Using log_dir: \t" . KM::$log_dir);
     $this->out("\nSending...");
     KM::send_logged_queries();
 }
开发者ID:servicerunner,项目名称:li3_kissmetrics,代码行数:14,代码来源:Kissmetrics.php


示例16: setUp

 protected function setUp()
 {
     if (empty($this->host)) {
         $this->host = Environment::get('resque.host');
     }
     if (empty($this->host)) {
         $this->host = 'localhost';
     }
     if (empty($this->port)) {
         $this->port = Environment::get('resque.port');
     }
     if (empty($this->port)) {
         $this->port = 6379;
     }
     ResqueProxy::setBackend($this->host . ':' . $this->port);
     $this->queues = ResqueProxy::queues();
 }
开发者ID:bruensicke,项目名称:li3_resque,代码行数:17,代码来源:Resque.php


示例17: run

 /**
  * Runs a test group or a specific test file based on the passed
  * parameters.
  *
  * @param string $group If set, this test group is run. If not set, a group test may
  *        also be run by passing the 'group' option to the $options parameter.
  * @param array $options Options array for the test run. Valid options are:
  *        - 'case': The fully namespaced test case to be run.
  *        - 'group': The fully namespaced test group to be run.
  *        - 'filters': An array of filters that the test output should be run through.
  * @return array A compact array of the title, an array of the results, as well
  *         as an additional array of the results after the $options['filters']
  *         have been applied.
  * @filter
  */
 public static function run($group = null, array $options = array())
 {
     $defaults = array('title' => $group, 'filters' => array(), 'reporter' => 'text');
     $options += $defaults;
     $isCase = is_string($group) && preg_match('/Test$/', $group);
     $items = $isCase ? array(new $group()) : (array) $group;
     $options['filters'] = Set::normalize($options['filters']);
     $group = static::_group($items);
     $report = static::_report($group, $options);
     return static::_filter(__FUNCTION__, compact('report'), function ($self, $params, $chain) {
         $environment = Environment::get();
         Environment::set('test');
         $params['report']->run();
         Environment::set($environment);
         return $params['report'];
     });
 }
开发者ID:nashadalam,项目名称:lithium,代码行数:32,代码来源:Dispatcher.php


示例18: __init

 /**
  *
  * @return void
  */
 public static function __init()
 {
     $libraryConfig = Libraries::get('li3_resque');
     static::config($libraryConfig + static::$_defaults);
     if (Environment::get('resque.host')) {
         static::$_config['host'] = Environment::get('resque.host');
     }
     if (Environment::get('resque.port')) {
         static::$_config['port'] = Environment::get('resque.port');
     }
     if (!empty(static::$_config['host']) || !empty(static::$_config['port'])) {
         try {
             Resque::setBackend(static::$_config['host'] . ':' . static::$_config['port']);
         } catch (Exception $e) {
             throw new ConfigException('Could not connect to Resque server');
         }
     }
 }
开发者ID:bruensicke,项目名称:li3_resque,代码行数:22,代码来源:ResqueProxy.php


示例19: terminate

 public static function terminate()
 {
     static::initSession();
     static::initAuth();
     static::$_data['end'] = microtime(true);
     static::$_data['environment'] = Environment::get();
     static::$_data['events.count'] = count(static::$_data['events']);
     static::$_data['db.count'] = count(static::$_data['db']);
     static::$_data['runtime'] = static::$_data['end'] - static::$_data['start'];
     static::$_data['memory.end'] = memory_get_usage(true);
     static::$_data['memory.usage'] = memory_get_peak_usage(true);
     static::$_data['log.count'] = count(static::$_data['log']);
     if (!Environment::is('production') && static::$_view) {
         try {
             echo static::$_view->render(array('element' => 'debug_bar'));
         } catch (\lithium\template\TemplateException $e) {
             $view = new View(array('paths' => array('element' => '{:library}/views/elements/{:template}.{:type}.php')));
             echo $view->render(array('element' => 'debug_bar'), array(), array('library' => 'li3_debug'));
         }
     }
 }
开发者ID:servicerunner,项目名称:li3_debug,代码行数:21,代码来源:Debugger.php


示例20: run

 /**
  * Dispatches a request based on a request object (an instance of `lithium\console\Request`).
  *  If `$request` is `null`, a new request object is instantiated based on the value of the
  * `'request'` key in the `$_classes` array.
  *
  * @param object $request An instance of a request object with console request information.  If
  *        `null`, an instance will be created.
  * @param array $options
  * @return object The command action result which is an instance of `lithium\console\Response`.
  * @filter
  */
 public static function run($request = null, $options = array())
 {
     $defaults = array('request' => array());
     $options += $defaults;
     $classes = static::$_classes;
     $params = compact('request', 'options');
     return static::_filter(__FUNCTION__, $params, function ($self, $params) use($classes) {
         $request = $params['request'];
         $options = $params['options'];
         $router = $classes['router'];
         $request = $request ?: new $classes['request']($options['request']);
         $request->params = $router::parse($request);
         $params = $self::applyRules($request->params);
         Environment::set($request);
         try {
             $callable = $self::invokeMethod('_callable', array($request, $params, $options));
             return $self::invokeMethod('_call', array($callable, $request, $params));
         } catch (UnexpectedValueException $e) {
             return (object) array('status' => $e->getMessage() . "\n");
         }
     });
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:33,代码来源:Dispatcher.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP core\Libraries类代码示例发布时间:2022-05-23
下一篇:
PHP analysis\Inspector类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap