本文整理汇总了PHP中lithium\core\Environment::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::get方法的具体用法?PHP Environment::get怎么用?PHP Environment::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\core\Environment
的用法示例。
在下文中一共展示了Environment::get方法的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;
}
示例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;
}
示例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)));
}
}
示例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;
}
示例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'];
}
示例6: 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']);
}
示例7: _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;
}
示例8: 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;
}
示例9: _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/";
}
示例10: setUp
public function setUp()
{
$this->_backup['catalogConfig'] = Catalog::config();
Catalog::reset();
Catalog::config(array('runtime' => array('adapter' => new Memory())));
$data = function ($n) {
return $n == 1 ? 0 : 1;
};
Catalog::write('runtime', 'message.pluralRule', 'root', $data);
$this->_backup['environment'] = Environment::get('test');
Environment::set('test', array('locale' => 'en'));
Environment::set('test');
Message::cache(false);
}
示例11: 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();
}
示例12: 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'];
});
}
示例13: 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();
}
示例14: __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');
}
}
}
示例15: 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'));
}
}
}