本文整理汇总了PHP中Config::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::load方法的具体用法?PHP Config::load怎么用?PHP Config::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @param string $key
* @return mixed
*/
public static function get($scope)
{
if (!isset(self::$settings[$scope])) {
self::$instance->load($scope);
}
return self::$settings[$scope];
}
示例2: _init
/**
* Init
*
* Loads in the config and sets the variables
*
* @access public
* @return void
*/
public static function _init()
{
\Config::load('breadcrumb', 'breadcrumb');
if (\Config::get('breadcrumb.auto_render', static::$auto_render) === true) {
static::initialise();
}
}
示例3: install
public static function install($package = null)
{
// Make sure something is set
if ($package === null) {
static::help();
return;
}
$config = \Config::load('package');
$version = \Cli::option('version', 'master');
// Check to see if this package is already installed
if (is_dir(PKGPATH . $package)) {
throw new Exception('Package "' . $package . '" is already installed.');
return;
}
foreach ($config['sources'] as $source) {
$packages = array('fuel-' . $package, $package);
foreach ($packages as $package) {
$zip_url = 'http://' . rtrim($source, '/') . '/' . $package . '/zipball/' . $version;
if ($fp = @fopen($zip_url, 'r')) {
// We don't actually need this, just checking the file is there
fclose($fp);
// Now, lets get this package
// If a direct download is requested, or git is unavailable, download it!
if (\Cli::option('direct') or static::_use_git() === false) {
static::_download_package_zip($zip_url, $package, $version);
exit;
} else {
static::_clone_package_repo($source, $package, $version);
exit;
}
}
}
}
throw new Exception('Could not find package "' . $package . '".');
}
示例4: instance
/**
* Get a instance.
*
* @return \Jobqueue\Context
*/
public static function instance()
{
if (is_null(static::$instance)) {
static::$instance = new static(\Fuel::$env, \Config::load('jobqueue', 'jobqueue'));
}
return static::$instance;
}
示例5: _init
/**
* Loads in the config and sets the variables
*/
public static function _init()
{
// Prevent multiple initializations
if (static::$initialized) {
return;
}
\Config::load('casset', true);
$paths = \Config::get('casset.paths', static::$asset_paths);
foreach ($paths as $key => $path) {
static::add_path($key, $path);
}
static::$asset_url = \Config::get('casset.url', \Config::get('base_url'));
static::$default_folders = array('css' => \Config::get('casset.css_dir', static::$default_folders['css']), 'js' => \Config::get('casset.js_dir', static::$default_folders['js']), 'img' => \Config::get('casset.img_dir', static::$default_folders['img']));
static::$cache_path = \Config::get('casset.cache_path', static::$cache_path);
static::$min_default = \Config::get('casset.min', static::$min_default);
static::$combine_default = \Config::get('casset.combine', static::$combine_default);
$group_sets = \Config::get('casset.groups', array());
foreach ($group_sets as $group_type => $groups) {
foreach ($groups as $group_name => $group) {
$enabled = array_key_exists('enabled', $group) ? $group['enabled'] : true;
$combine = array_key_exists('combine', $group) ? $group['combine'] : null;
$min = array_key_exists('min', $group) ? $group['min'] : null;
static::add_group($group_type, $group_name, $enabled, $combine, $min);
foreach ($group['files'] as $files) {
if (!is_array($files)) {
$files = array($files, false);
}
static::add_asset($group_type, $files[0], $files[1], $group_name);
}
}
}
static::$show_files = \Config::get('casset.show_files', static::$show_files);
static::$show_files_inline = \Config::get('casset.show_files_inline', static::$show_files_inline);
static::$initialized = true;
}
示例6: load
protected function load($menu = null)
{
$menu = $menu ?: $this->menu;
$data = \Config::load('menu/' . $menu, true, true, true);
$this->meta = array('name' => \Arr::get($data, 'name'), 'identifier' => \Arr::get($data, 'slug'), 'num_items' => $this->count($data['children']));
return $data;
}
示例7: __construct
/**
* Sets the initial Ftp filename and local data.
*
* @param string Ftp filename
* @param array array of values
* @return void
*/
public function __construct($config = 'default')
{
\Config::load('ftp', true);
// If it is a string we're looking at a predefined config group
if (is_string($config))
{
$config_arr = \Config::get('ftp.'.$config);
// Check that it exists
if ( ! is_array($config_arr) or $config_arr === array())
{
throw new \Exception('You have specified an invalid ftp connection group: '.$config);
}
$config = $config_arr;
}
// Prep the hostname
$this->_hostname = preg_replace('|.+?://|', '', $config['hostname']);
$this->_username = $config['username'];
$this->_password = $config['password'];
$this->_port = ! empty($config['port']) ? (int) $config['port'] : 21;
$this->_passive = (bool) $config['passive'];
$this->_ssl_mode = (bool) $config['ssl_mode'];
$this->_debug = (bool) $config['debug'];
static::$initialized = true;
}
示例8: _init
/**
* Initialize
*/
public static function _init()
{
$config = \Config::load('sentry', true);
static::$config = $config[\Fuel::$env];
// create instance for PHP
static::$client = new \Raven_Client(static::$config['php']['dsn']);
}
示例9: run
public function run()
{
$url = 'http://' . (getenv('WEB_HOST') ? getenv('WEB_HOST') : 'localhost');
$output = APPPATH . '/cache/benchmark-results.json';
\Config::load('orms', true);
$orms = \Config::get('orms.list');
$data = [];
$errors = [];
foreach ($orms as $orm) {
echo 'Benchmarking ' . $orm . ' ...';
try {
$time = 0;
$memory = 0;
for ($i = 0; $i < 100; $i++) {
$result = file_get_contents($url . '/orm/' . $orm . '/get_one');
$tmp = explode("\n", $result);
// var_dump($tmp);
$time += (double) trim($tmp[2], ' sec');
$memory += (double) trim($tmp[3], ' KB');
}
$time = $time / $i * 1000;
$memory = $memory / $i;
echo "\t" . substr($time, 0, 9) . 'ms ' . "\t" . $memory . 'KB' . PHP_EOL;
$data[$orm] = array('time' => $time, 'memory' => $memory);
} catch (\Exception $e) {
$errors[$orm] = (string) $e;
echo "\tfailed!\n";
}
}
foreach ($errors as $orm => $error) {
echo "\n{$orm} failed with exception:\n{$error}\n";
}
file_put_contents($output, json_encode($data));
}
示例10: __construct
function __construct($app_name)
{
$config = \Config::load('google', true);
$this->_client = new \apiClient();
if ($app_name != null && $app_name != "") {
$this->_client->setApplicationName($app_name);
}
foreach ($config as $key => $value) {
if ($value != null && $value != "") {
switch ($key) {
case "client_id":
$this->_client->setClientId($value);
break;
case "client_secret":
$this->_client->setClientSecret($value);
break;
case "redirect_uri":
$this->_client->setRedirectUri($value);
break;
case "developer_key":
$this->_client->setDeveloperKey($value);
break;
}
}
}
}
示例11: _init
public static function _init()
{
\Config::load('complexauth', true, true, true);
if (\Config::get('complexauth.remember_me.enabled', false)) {
static::$remember_me = \Session::forge(array('driver' => 'cookie', 'cookie' => array('cookie_name' => \Config::get('complexauth.remember_me.cookie_name', 'rmcookie')), 'encrypt_cookie' => true, 'expire_on_close' => false, 'expiration_time' => \Config::get('complexauth.remember_me.expiration', 86400 * 31)));
}
}
示例12: action_settings
/**
* Setting the display of pages
*
* @uses Arr::merge
* @uses Config::load
* @uses Message::success
*/
public function action_settings()
{
$this->title = __('Page Settings');
$post = Config::load('page');
$action = Route::get('admin/page')->uri(array('action' => 'settings'));
$vocabs = array(__('none'));
$view = View::factory('admin/page/settings')->set('vocabs', $vocabs)->set('post', $post)->set('action', $action);
$vocabs = Arr::merge($vocabs, ORM::factory('term')->where('lft', '=', 1)->where('type', '=', 'page')->find_all()->as_array('id', 'name'));
if ($this->valid_post('page_settings')) {
unset($_POST['page_settings'], $_POST['_token'], $_POST['_action']);
$cats = $post->get('category', array());
foreach ($_POST as $key => $value) {
if ($key == 'category') {
$terms = array_diff($cats, $value);
if ($terms) {
DB::delete('posts_terms')->where('parent_id', 'IN', array_values($terms))->execute();
}
}
$post->set($key, $value);
}
Log::info('Page Settings updated.');
Message::success(__('Page Settings updated!'));
$this->request->redirect(Route::get('admin/page')->uri(array('action' => 'settings')), 200);
}
$this->response->body($view);
}
示例13: action_main
public function action_main($params = array())
{
$config = $this->config;
$gConfig = \Config::load('novius_social_widget::config', true);
if (Arr::get($gConfig, 'embed_js', true)) {
if (!empty($config['js'])) {
foreach ($config['js'] as $script) {
Nos::main_controller()->addJavascript($script);
}
}
}
$chrome = array();
$typeList = array('chrome');
foreach ($params as $param => $value) {
if ($value) {
foreach ($typeList as $type) {
$typePrefix = "{$type}-";
if ($value && \Str::starts_with($param, $typePrefix)) {
array_push(${$type}, \Str::sub($param, \Str::length($typePrefix)));
}
}
}
}
return \View::forge('novius_social_widget::front/enhancer/twitter', array('widgetId' => $params['widget-id'], 'chrome' => $chrome, 'limit' => \Arr::get($params, 'limit'), 'width' => \Arr::get($params, 'width'), 'height' => \Arr::get($params, 'height')), false);
}
示例14: __construct
/**
* Construct
*
* Called when the class is initialised
*
* @access protected
* @return PDF\PDF
*/
protected function __construct($driver = null)
{
// Load Config
\Config::load('pdf', true);
// Default Driver
if ($driver == null) {
$driver = \Config::get('pdf.default_driver');
}
// Set the lib path
$this->set_lib_path(PKGPATH . 'pdf' . DS . 'lib' . DS);
$drivers = \Config::get('pdf.drivers');
$temp_driver = isset($drivers[$driver]) ? $drivers[$driver] : false;
if ($temp_driver === false) {
throw new \Exception(sprintf('Driver \'%s\' doesn\'t exist.', $driver));
}
$driver = $temp_driver;
// Include files
foreach ($driver['includes'] as $include) {
include_once $this->_get_include_file($include);
}
$this->set_driver_class($driver['class']);
// Return this object. User must now call init and provide the parameters that
// the driver wants. This action is caught by __call()
return $this;
}
示例15: split
/**
* Return all defined permissions (results get stored at the first run)
*
*
*
* @return array
*/
public function split($exclude)
{
static $list = null;
if ($list == null) {
$perms = array('free' => array(), 'excluded' => array());
$paths = array_keys(Kohana::list_files('permissions'));
foreach ($paths as $path) {
$set = str_replace(array('permissions' . DIRECTORY_SEPARATOR, '.php'), '', $path);
$list = $this->_list->load($set)->as_array();
foreach ($list as $k => $v) {
if (is_int($k)) {
if (!in_array($set . '.' . $v, $exclude)) {
$perms['free'][] = $set . '.' . $v;
} else {
$perms['excluded'][] = $set . '.' . $v;
}
} else {
$perms = $this->_process_perms_split($v, $set . '.' . $k, $perms, $exclude);
}
}
}
$list = $perms;
}
sort($perms['excluded']);
sort($perms['free']);
return $list;
}