本文整理汇总了PHP中Configure::config方法的典型用法代码示例。如果您正苦于以下问题:PHP Configure::config方法的具体用法?PHP Configure::config怎么用?PHP Configure::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configure
的用法示例。
在下文中一共展示了Configure::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _configTestFile
protected function _configTestFile($path = null, $baseKey = null)
{
if ($path === null) {
$path = CakePlugin::path('YamlReader') . 'Test' . DS . 'files' . DS;
}
Configure::config('YamlTestConfig', new YamlReader($path, $baseKey));
}
示例2: beforeFilter
public function beforeFilter()
{
parent::beforeFilter();
Configure::config('configini', new IniReader());
Configure::load('config.ini', 'configini');
/*
* "Auth" logic
* Generate and test the security key
*/
$api = json_decode($this->Setting->getOption('api'));
if (empty($api) || empty($api->enabled) || !$api->enabled) {
return $this->api401(__('API is disabled'));
}
// No key, refuse connexion
if (empty($this->request->params['named']) || empty($this->request->params['named']['key'])) {
return $this->api401(__('Security key is missing'));
}
// Get the key and remote it from the params
$theirSecurityKey = $this->request->params['named']['key'];
unset($this->request->params['named']['key']);
// generate the security key
$paramsUrl = '/' . $this->request->params['controller'] . '/' . $this->request->params['action'];
$paramsUrl .= $this->Tools->paramsToUrl($this->request->params['named']);
$securityKey = hash_hmac('sha1', $paramsUrl, $api->privateKey);
if ($theirSecurityKey != $securityKey) {
return $this->api401(__('Wrong security key'));
}
}
示例3: _configTestFile
protected function _configTestFile($domain = null, $path = null, $baseKey = null)
{
if ($path === null) {
$path = App::pluginPath('YamlReader') . 'Test' . DS . 'files' . DS;
}
Configure::config('I18nYamlTestConfig', new I18nYamlReader($domain, $path, $baseKey));
}
示例4: beforeFilter
public function beforeFilter()
{
parent::beforeFilter();
App::uses('CloggyModuleConfigReader', 'CustomConfigure');
Configure::config('cloggy', new CloggyModuleConfigReader('CloggySearch'));
//disable auto render
$this->autoRender = false;
}
示例5: setupSettings
public function setupSettings($appDir)
{
if (!$this->setupSettings) {
return;
}
$Setting = ClassRegistry::init('Settings.Setting');
$Setting->settingsPath = $appDir . 'Config' . DS . 'settings.json';
Configure::drop('settings');
Configure::config('settings', new CroogoJsonReader(dirname($Setting->settingsPath) . DS));
$Setting->writeConfiguration();
}
示例6: setUp
/**
* setUp
*
* @return void
*/
public function setUp()
{
parent::setUp();
App::build(array('Plugin' => array(TESTS . 'test_app' . DS . 'Plugin' . DS), 'View' => array(TESTS . 'test_app' . DS . 'View' . DS)), App::PREPEND);
CakePlugin::unload('Install');
CakePlugin::load('Example');
Configure::write('Acl.database', 'test');
$Setting = ClassRegistry::init('Settings.Setting');
$Setting->settingsPath = TESTS . 'test_app' . DS . 'Config' . DS . 'settings.json';
Configure::drop('settings');
Configure::config('settings', new CroogoJsonReader(dirname($Setting->settingsPath) . DS));
$Setting->writeConfiguration();
}
示例7: __construct
function __construct()
{
Configure::config('configini', new IniReader());
Configure::load('config.ini', 'configini');
if ($databaseConf = Configure::read('Database')) {
$this->default['datasource'] = $databaseConf['datasource'];
$this->default['host'] = $databaseConf['host'];
$this->default['login'] = $databaseConf['login'];
$this->default['password'] = $databaseConf['password'];
$this->default['database'] = $databaseConf['database'];
$this->default['prefix'] = $databaseConf['prefix'];
$this->default['port'] = $databaseConf['port'];
}
}
示例8: beforeFilter
public function beforeFilter()
{
parent::beforeFilter();
// Check conf file
if (!file_exists('../Config/config.ini')) {
file_put_contents('../Config/config.ini', '');
}
Configure::config('configini', new IniReader());
Configure::load('config.ini', 'configini');
// If config isn't set, redirect to install process to create one
if (!Configure::read('Settings.installed') && strtolower($this->plugin) != 'install') {
$this->Session->setFlash(__('MushRaider is ready for install, what about you ?'), 'flash_info');
$this->redirect('/install/step/1');
}
// Language
$language = Configure::read('Settings.language');
$language = $this->Cookie->check('Lang') ? $this->Cookie->read('Lang') : $language;
$language = !empty($language) ? $language : 'eng';
Configure::write('Config.language', $language);
// Some usefull infos
Configure::write('Config.maxFileSize', ini_get('upload_max_filesize'));
Configure::write('Config.maxPostSize', ini_get('post_max_size'));
Configure::write('Config.appUrl', rtrim('http://' . $_SERVER['HTTP_HOST'] . $this->webroot, '/'));
// Timezone
date_default_timezone_set($this->Setting->getOption('timezone'));
// Log in user
if ($this->Session->check('User.id')) {
$userID = $this->Session->read('User.id');
if (!empty($userID)) {
$params = array();
$params['recursive'] = 1;
$params['contain']['Role'] = array();
$params['contain']['Character'] = array();
$params['conditions']['User.id'] = $userID;
if ($this->user = $this->User->find('first', $params)) {
$this->user['User']['can'] = $this->Role->getPermissions($this->user['User']['role_id']);
}
} else {
$this->Session->delete('User.id');
}
}
// Is a patch needed ?
if (strtolower($this->name) != 'patcher' && strtolower($this->name) != 'auth') {
$this->Patcher->patchNeeded();
}
$this->pageTitle = $this->Setting->getOption('title');
Configure::write('Config.email', json_decode($this->Setting->getOption('email')));
Configure::write('Config.notifications', json_decode($this->Setting->getOption('notifications')));
}
示例9: __construct
/**
* Constructor
*
* @param mixed $id The id to start the model on.
* @param string $table The table to use for this model.
* @param string $ds The connection name this model is connected to.
*/
public function __construct($id = false, $table = null, $ds = null)
{
parent::__construct($id, $table, $ds);
Configure::config('default', new PhpReader(ROOT . '/plugins/Tools/Config/'));
Configure::load('google', 'default');
set_include_path(ROOT . '/plugins/Tools/Lib/' . PATH_SEPARATOR . get_include_path());
require_once 'Google/Client.php';
require_once 'Google/Service/Calendar.php';
$this->__client = new Google_Client();
$this->__client->setClientId(Configure::read('google_client_id'));
$this->__client->setClientSecret(Configure::read('google_client_secret'));
$this->__client->setRedirectUri(Configure::read('google_redirect_url'));
$this->__client->setAccessType('offline');
$this->__client->addScope("https://www.googleapis.com/auth/calendar");
$this->__service = new Google_Service_Calendar($this->__client);
}
示例10: __construct
/**
* Constructor
*
* @param mixed $id The id to start the model on.
* @param string $table The table to use for this model.
* @param string $ds The connection name this model is connected to.
*/
public function __construct($id = false, $table = null, $ds = null)
{
parent::__construct($id, $table, $ds);
Configure::config('default', new PhpReader());
Configure::load('mailchimp', 'default');
// Set-up mailchimp
$this->apikey = Configure::read('mailchimp_apiKey');
$this->__api = new MCAPI($this->apikey, true);
// Bit hacky, we need to tell the MCAPI class
// which dbConfig to use, but we can't add a method on
// to the production MCAPI class, so we have to check if
// it exists first.
if (method_exists($this->__api, 'setConfig')) {
$this->__api->setConfig($this->useDbConfig);
}
}
示例11: __construct
/**
* __construct
* @param array $config
* @param string $path
*/
public function __construct($config = array(), $path = null)
{
if (!$path) {
$path = APP . 'Config' . DS;
}
Configure::delete('Oven');
if (empty($config)) {
$try = array($path . 'oven.json', $path . 'oven.php');
foreach ($try as $cfg) {
if (file_exists($cfg)) {
$this->path = $cfg;
$ext = strrchr($cfg, '.');
switch ($ext) {
case '.json':
App::uses('File', 'Utility');
$cfg = new File($cfg);
$this->config = json_decode($cfg->read(), true);
break;
case '.yaml':
App::import('Vendor', 'Oven.spyc/spyc');
$this->config = Spyc::YAMLLoad($cfg);
break;
default:
App::uses('PhpReader', 'Configure');
Configure::config('oven', new PhpReader(dirname($cfg) . DS));
Configure::load('oven', 'oven');
$this->config = Configure::read('Oven');
break;
}
break;
}
}
// IF NO CONFIG COPY OVER SAMPLE
if (empty($this->config)) {
if (copy(CakePlugin::path('Oven') . 'Config' . DS . 'config.json', $path . 'oven.json')) {
$this->__construct();
}
}
} else {
$this->config = $config;
}
$this->config = $this->_default($this->config);
Configure::write('Oven', $this->config);
}
示例12: beforeFilter
public function beforeFilter()
{
parent::beforeFilter();
if (!file_exists('../Config/config.ini')) {
file_put_contents('../Config/config.ini', '');
}
Configure::config('configini', new IniReader());
Configure::load('config.ini', 'configini');
// If config already set, redirect to root
if (file_exists('../Config/config.ini')) {
if (Configure::read('Settings.installed')) {
$this->Session->setFlash(__('MushRaider can see the database config, why do you want to install ?'), 'flash_warning');
$this->redirect('/');
}
}
$this->set('title_for_layout', __('MushRaider Installer'));
$languages = array('eng' => 'English', 'fra' => 'Français', 'deu' => 'Deutsch');
$this->set('languages', $languages);
}
示例13: setUp
/**
* setUp
*
* @return void
*/
public function setUp()
{
parent::setUp();
App::build(array('Plugin' => array(TESTS . 'test_app' . DS . 'Plugin' . DS), 'View' => array(TESTS . 'test_app' . DS . 'View' . DS)), App::PREPEND);
if (!isset($_SERVER['REMOTE_ADDR'])) {
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
}
CakePlugin::unload('Install');
CakePlugin::load(array('Users'), array('bootstrap' => true));
CakePlugin::load('Example');
Configure::write('Acl.database', 'test');
$Setting = ClassRegistry::init('Settings.Setting');
$Setting->settingsPath = TESTS . 'test_app' . DS . 'Config' . DS . 'settings.json';
Configure::drop('settings');
Configure::config('settings', new CroogoJsonReader(dirname($Setting->settingsPath) . DS));
CakeLog::drop('stdout');
CakeLog::drop('stderr');
$Setting->writeConfiguration();
}
示例14: __construct
/**
* Constructor.
*/
public function __construct()
{
Configure::config('default', new PhpReader());
Configure::load('automation', 'default');
//Configure::load('routes', 'default');
$phpSelf = $_SERVER['PHP_SELF'];
$selfParts = explode('/', $phpSelf);
$this->__rootUrl = '';
$partIndex = 0;
$firstPart = true;
$numParts = count($selfParts);
while ($selfParts[$partIndex] != 'app' && $partIndex < $numParts) {
if ($selfParts[$partIndex] != '') {
if (!$firstPart) {
$this->__rootUrl .= '/';
}
$firstPart = false;
$this->__rootUrl .= $selfParts[$partIndex];
}
$partIndex++;
}
$this->__webDriver = new PHPWebDriver_WebDriver(Configure::read('automation_driver_selenium_url'));
new CakeRequest();
}
示例15: testReaderExceptionOnIncorrectClass
/**
* test reader() throwing exceptions on missing interface.
*
* @expectedException PHPUnit_Framework_Error
* @return void
*/
public function testReaderExceptionOnIncorrectClass()
{
$reader = new StdClass();
Configure::config('test', $reader);
}