Gets the current environment name, a setting associated with the current environment, or the
entire configuration array for the current environment.
public static get ( string $name = null ) : mixed | ||
$name | string | The name of the environment setting to retrieve, or the name of an environment, if that environment's entire configuration is to be retrieved. If retrieving the current environment name, `$name` should not be passed. |
리턴 | mixed | If `$name` is unspecified, returns the name of the current environment name as a string (i.e. `'production'`). If an environment name is specified, returns that environment's entire configuration as an array. |
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; }
/** * 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; }
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))); } }
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; }
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']; }
/** * 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']); }
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; }
/** * 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; }
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/"; }
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); }
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(); }
/** * 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']; }); }
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(); }
/** * * @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'); } } }
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')); } } }
/** * Gets an array of settings for the given named configuration in the current * environment. * * @see lithium\core\Environment * @param string $name Name of the configuration. * @return array Settings of the named configuration. */ public function get($name = null) { if ($name === null) { $result = array(); $this->_configurations = array_filter($this->_configurations); foreach ($this->_configurations as $key => $value) { $result[$key] = $this->get($key); } return $result; } $settings =& $this->_configurations; if (!isset($settings[$name])) { return null; } if (isset($settings[$name][0])) { return $settings[$name][0]; } $env = Environment::get(); $config = isset($settings[$name][$env]) ? $settings[$name][$env] : $settings[$name]; $method = is_callable($this->initConfig) ? $this->initConfig : null; $settings[$name][0] = $method ? $method($name, $config) : $config; return $settings[$name][0]; }
public function match(array $options = array(), $context = null) { $locale = Environment::get('locale'); return parent::match($options + compact('locale'), $context); }
<?php /** * Lithium: the most rad php framework * * @copyright Copyright 2012, Union of Rad, Inc. (http://union-of-rad.org) * @license http://opensource.org/licenses/bsd-license.php The BSD License */ use lithium\core\Environment; ?> <div id="locale-navigation"> <ul> <?php foreach (Environment::get('locales') as $locale => $name) { ?> <li><?php echo $this->html->link($name, compact('locale') + $this->_request->params); ?> </li> <?php } ?> </ul> </div>
use Airbrake\Connection; use Airbrake\EventHandler; use Airbrake\Exception; use Airbrake\Notice; use Airbrake\Record; use Airbrake\Version; $_config = Libraries::get('li3_airbrake'); if (isset($_config['apiKey']) && !empty($_config['apiKey'])) { if (!isset($_config['notifyOnWarning']) || empty($_config['notifyOnWarning'])) { $_config['notifyOnWarning'] = (bool) (E_NOTICE & error_reporting()); } if (!isset($_config['options'])) { $_config['options'] = array(); } if (!isset($_config['options']['environmentName']) || empty($_config['options']['environmentName'])) { $_config['options']['environmentName'] = Environment::get(); } if (!isset($_config['options']['projectRoot']) || empty($_config['options']['projectRoot'])) { $_config['options']['projectRoot'] = LITHIUM_APP_PATH; } // Setup Airbrake $config = new Configuration($_config['apiKey'], $_config['options']); $client = new Client($config); $handler = new EventHandler($client, (bool) $_config['notifyOnWarning']); // Apply Error handler set_error_handler(function ($errno, $errstr, $errfile = null, $errline = 0, array $errcontext = array()) use($handler) { $handler->onError($errno, $errstr, $errfile, $errline, $errcontext); }); // Apply Exception handler // $previousExceptionHandler = set_exception_handler(); // set_exception_handler(function($exception) use ($handler, $previousExceptionHandler) {
public function testEnv() { $this->response->environment = Environment::get(); }
* @see lithium\net\http\Router * @see lithium\net\http\Route */ use lithium\net\http\Router; use lithium\core\Environment; /** * ### Continuation routes * * With globalization enabled a localized route is configured by connecting a * continuation route. Once the route has been connected, all the other * application routes become localized and may now carry a locale. * * Requests to routes like `/en/posts/edit/1138` or `/fr/posts/edit/1138` will * carry a locale, while `/posts/edit/1138` keeps on working as it did before. */ if ($locales = Environment::get('locales')) { $template = '/{:locale:' . join('|', array_keys($locales)) . '}/{:args}'; Router::connect($template, array(), array('continue' => true)); } /** * ### Basic page routes * * Here, we are connecting `'/'` (the base path) to controller called `'Pages'`, * its action called `view()`, and we pass a param to select the view file * to use (in this case, `/views/pages/home.html.php`; see `app\controllers\PagesController` * for details). * * @see app\controllers\PagesController */ Router::connect('/', 'Pages::view'); /**
<?php use lithium\core\Environment; if (substr(Environment::get('locale'), 0, 2) == "en") { $locale = "en"; } else { $locale = Environment::get('locale'); } //if(strlen($locale>2)){$locale='en';} // print_r(Environment::get('locale')); // print_r($locale); ?> <div class="well"> </div> <div><h3><?php echo $t('Privacy Policy'); ?> </h3></div> <div class="container-fluid"><p> </p> <p><?php echo $t('This Privacy Policy explains how information about you is collected, used and disclosed by'); ?> <strong>GreenCoinX Inc.</strong> <?php echo $t('doing business as XGC Wallet'); ?> ("<strong><?php echo $t('we'); ?> </strong>" <?php echo $t('or'); ?> "<strong><?php
/** * Run a task * * @param string $task Fully qualified class name, with optional method name * @param array $args Arguments to pass to the task * @param array $options Options: * - DateTime schedule: If specified, run at this time * - boolean background: wether to run task in * background * - string id: Identifier for this task (auto generates * one if none specified) * - mixed unique: If true, generate a unique ID so two * tasks with the same workload are considered equal. * If string, use this unique ID for this task. If empty * or false, do not treat this as a unique task. * - string priority: Prority. One of: low, normal, * high * - array env: array of environment settings to set * (from $_SERVER) for proper routing. If omitted, * automatically set this. * @return mixed If background, job handle. Otherwise job's return value */ public function run($task, array $args, array $options) { $options += ['configName' => null, 'background' => true, 'unique' => false, 'id' => null, 'priority' => 'normal', 'schedule' => null, 'env' => array_intersect_key($_SERVER, ['HTTP_HOST' => null, 'SCRIPT_FILENAME' => null, 'SCRIPT_NAME' => null, 'PHP_SELF' => null, 'HTTPS' => null]), 'retries' => [], 'retry' => 0]; if (!empty($options['retries'])) { if (!is_array($options['retries'])) { $options['retries'] = ['maximum' => $options['retries']]; } $options['retries'] += ['maximum' => 5, 'increment' => ['5 minutes', '10 minutes', '20 minutes', '30 minutes', '50 minutes']]; $lastIncrement = is_array($options['retries']['increment']) ? end($options['retries']['increment']) : $options['retries']['increment']; $increments = is_array($options['retries']['increment']) ? count($options['retries']['increment']) : 0; if (!is_array($options['retries']['increment']) || $increments < $options['retries']['maximum']) { if (!is_array($options['retries']['increment'])) { $options['retries']['increment'] = []; } $options['retries']['increment'] = array_merge($options['retries']['increment'], array_fill(0, $options['retries']['maximum'] - $increments, $lastIncrement)); } } if (empty($options['configName'])) { throw new InvalidArgumentException('Missing configuration name'); } elseif (!in_array($options['priority'], ['low', 'normal', 'high'])) { throw new InvalidArgumentException("Invalid priority {$options['priority']}"); } elseif (isset($options['schedule'])) { if (!$options['schedule'] instanceof DateTime) { throw new InvalidArgumentException('Invalid value specified for schedule option'); } elseif (!$options['background']) { throw new InvalidArgumentException('Only background tasks can be scheduled'); } elseif ($options['schedule']->getTimezone()->getName() !== 'UTC') { throw new InvalidArgumentException('Schedule time should be specified in UTC'); } $now = new DateTime('now', new DateTimeZone('UTC')); if ($now >= $options['schedule']) { $options['schedule'] = null; } } if ($task[0] !== '\\') { $task = '\\' . $task; } if (strpos($task, '::') === false) { $task .= '::run'; } $action = null; switch ($options['priority']) { case 'low': $action = $options['background'] ? 'doLowBackground' : 'doLow'; break; case 'normal': $action = $options['background'] ? 'doBackground' : (method_exists($this->client, 'doNormal') ? 'doNormal' : 'do'); break; case 'high': $action = $options['background'] ? 'doHighBackground' : 'doHigh'; break; } if (empty($action)) { throw new InvalidArgumentException('Could not map priority to a gearman action'); } $id = !empty($options['id']) ? $options['id'] : sha1(uniqid(time(), true)); $env = $options['env']; $env['environment'] = Environment::get(); $workload = ['id' => $id, 'args' => $args, 'env' => $env, 'configName' => $options['configName'], 'task' => $task, 'background' => $options['background'], 'retry' => $options['retry'], 'retries' => $options['retries']]; if ($options['schedule']) { return $this->schedule($options['schedule'], $id, $action, $workload, $options); } return $this->queue($id, $action, $workload, $options); }
/** * Translates a message according to the current or provided locale * and into its correct plural form. * * Usage: * ``` * Message::translate('Mind the gap.'); * Message::translate('house', array('count' => 23)); * ``` * * `String::insert()`-style placeholders may be used within the message * and replacements provided directly within the `options` argument. * * Example: * ``` * Message::translate('I can see {:count} bike.'); * Message::translate('This painting is {:color}.', array( * 'color' => Message::translate('silver'), * )); * ``` * * @see lithium\util\String::insert() * @param string $id The id to use when looking up the translation. * @param array $options Valid options are: * - `'count'`: Used to determine the correct plural form. You can either pass * a signed or unsigned integer, the behavior when passing other types * is yet undefined. * The count is made absolute before being passed to the pluralization * function. This has the effect that that with i.e. an English * pluralization function passing `-1` results in a singular * translation. * - `'locale'`: The target locale, defaults to current locale. * - `'scope'`: The scope of the message. * - `'context'`: The disambiguating context (optional). * - `'default'`: Is used as a fall back if `_translated()` returns * without a result. * - `'noop'`: If `true` no whatsoever lookup takes place. * @return string The translation or the value of the `'default'` option if none * could be found. */ public static function translate($id, array $options = array()) { $defaults = array('count' => 1, 'locale' => Environment::get('locale'), 'scope' => null, 'context' => null, 'default' => null, 'noop' => false); $options += $defaults; if ($options['noop']) { $result = null; } else { $result = static::_translated($id, abs($options['count']), $options['locale'], array('scope' => $options['scope'], 'context' => $options['context'])); } if ($result = $result ?: $options['default']) { return strpos($result, '{:') !== false ? String::insert($result, $options) : $result; } }
/** * Tests calling `get()` and `set()` with `true` as the envrionment name, to automatically * select the current environment. * * @return void */ public function testReadWriteWithDefaultEnvironment() { Environment::set('development'); Environment::set(true, array('foo' => 'bar')); $this->assertEqual(array('foo' => 'bar'), Environment::get('development')); $this->assertEqual(Environment::get(true), Environment::get('development')); Environment::set('production'); $this->assertFalse(Environment::get(true)); }
public function testCustomAssetUrls() { $env = Environment::get(); Libraries::add('cdn_js_test', array('path' => Libraries::get(true, 'path'), 'assets' => array('js' => 'http://static.cdn.com'))); Libraries::add('cdn_env_test', array('path' => Libraries::get(true, 'path'), 'assets' => array('js' => 'wrong', $env => array('js' => 'http://static.cdn.com/myapp')))); $result = Media::asset('foo', 'js', array('library' => 'cdn_js_test')); $this->assertEqual("http://static.cdn.com/lithium/js/foo.js", $result); $result = Media::asset('foo', 'css', array('library' => 'cdn_js_test')); $this->assertEqual("/lithium/css/foo.css", $result); $result = Media::asset('foo', 'js', array('library' => 'cdn_env_test')); $this->assertEqual("http://static.cdn.com/myapp/lithium/js/foo.js", $result); Libraries::remove('cdn_env_test'); Libraries::remove('cdn_js_test'); }
}); /** * Integration with `Validator`. You can load locale dependent rules into the `Validator` * by specifying them manually or retrieving them with the `Catalog` class. */ foreach (array('phone', 'postalCode', 'ssn') as $name) { Validator::add($name, Catalog::read(true, "validation.{$name}", 'en_US')); } /** * Intercepts dispatching processes in order to set the effective locale by using * the locale of the request or if that is not available retrieving a locale preferred * by the client. */ ActionDispatcher::applyFilter('_callable', function ($self, $params, $chain) { $request = $params['request']; $controller = $chain->next($self, $params, $chain); if (!$request->locale) { $request->params['locale'] = Locale::preferred($request); } Environment::set(Environment::get(), array('locale' => $request->locale)); return $controller; }); ConsoleDispatcher::applyFilter('_callable', function ($self, $params, $chain) { $request = $params['request']; $command = $chain->next($self, $params, $chain); if (!$request->locale) { $request->params['locale'] = Locale::preferred($request); } Environment::set(Environment::get(), array('locale' => $request->locale)); return $command; });
/** * Create environment prefix location using `lihtium\net\http\Media::location` * Check if `lihtium\net\http\Media::asset` return the correct URL * for the test environement */ public function testEnvironmentAsset2() { Media::attach('appcdn', array('production' => array('absolute' => true, 'path' => null, 'scheme' => 'http://', 'host' => 'my.cdnapp.com', 'prefix' => 'assets'), 'test' => array('absolute' => true, 'path' => null, 'scheme' => 'http://', 'host' => 'my.cdntest.com', 'prefix' => 'assets'))); $env = Environment::get(); Environment::set('test'); $result = Media::asset('style', 'css', array('scope' => 'appcdn')); $expected = 'http://my.cdntest.com/assets/css/style.css'; $this->assertEqual($expected, $result); Environment::is($env); }
/** * Translates a message according to the current or provided locale * and into it's correct plural form. * * Usage: * {{{ * Message::translate('Mind the gap.'); * Message::translate('house', array('count' => 23)); * }}} * * `String::insert()`-style placeholders may be used within the message * and replacements provided directly within the `options` argument. * * Example: * {{{ * Message::translate('I can see {:count} bike.'); * Message::translate('This painting is {:color}.', array( * 'color' => Message::translate('silver'), * )); * }}} * * @see lithium\util\String::insert() * @param string $id The id to use when looking up the translation. * @param array $options Valid options are: * - `'count'`: Used to determine the correct plural form. You can either pass * a signed or unsigned integer, the behavior when passing other types * is yet undefined. * The count is made absolute before being passed to the pluralization * function. This has the effect that that with i.e. an English * pluralization function passing `-1` results in a singular * translation. * - `'locale'`: The target locale, defaults to current locale. * - `'scope'`: The scope of the message. * - `'default'`: Is used as a fall back if `_translated()` returns * without a result. * - `'noop'`: If `true` no whatsoever lookup takes place. * @return string|void The translation or the value of the `'default'` option if none * could be found. */ public static function translate($id, array $options = array()) { $defaults = array('count' => 1, 'locale' => Environment::get('locale'), 'scope' => null, 'default' => null, 'noop' => false); extract($options + $defaults); if ($noop) { $result = null; } else { $result = static::_translated($id, abs($count), $locale, compact('scope')); } if ($result || $default) { return String::insert($result ?: $default, $options); } }
/** * Gets an array of settings for the given named configuration in the current * environment. * * The default types of settings for all adapters will contain keys for: * `adapter` - The class name of the adapter * `filters` - An array of filters to be applied to the adapter methods * * @see lithium\core\Environment * @param string $name Named configuration. * @return array Settings for the named configuration. */ protected static function _config($name) { if (!isset(static::$_configurations[$name])) { return null; } $settings = static::$_configurations[$name]; if (isset($settings[0])) { return $settings[0]; } $env = Environment::get(); $config = isset($settings[$env]) ? $settings[$env] : $settings; if (isset($settings[$env]) && isset($settings[true])) { $config += $settings[true]; } static::$_configurations[$name] += array(static::_initConfig($name, $config)); return static::$_configurations[$name][0]; }