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


PHP core\Environment类代码示例

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


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


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