本文整理匯總了PHP中Current::initialize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Current::initialize方法的具體用法?PHP Current::initialize怎麽用?PHP Current::initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Current
的用法示例。
在下文中一共展示了Current::initialize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct()
{
Cowl::timer('cowl init');
@session_start();
// I know that the @-notation is frowned upon, but adding it to session_start saves us unnecessary warnings
Cache::setDir(COWL_CACHE_DIR);
Current::initialize(COWL_DIR);
if (COWL_CLI) {
$this->parseCLIPath();
} else {
$this->parseRequestPath();
}
Cowl::timer('cowl set defaults');
// Get and set all directories for various things.
list($commands_dir, $model_dir, $validators_dir, $library_dir, $view_dir, $helpers_dir, $helpers_app_dir, $drivers_dir, $app_dir, $view_layout_dir, $validator_error_messages, $lang) = Current::$config->gets('paths.commands', 'paths.model', 'paths.validators', 'paths.library', 'paths.view', 'paths.helpers', 'paths.helpers_app', 'paths.drivers', 'paths.app', 'paths.layouts', 'paths.validator_messages', 'lang');
Controller::setDir($commands_dir);
DataMapper::setMappersDir($model_dir);
DataMapper::setObjectsDir($model_dir);
Validator::setPath($validators_dir);
Validator::loadStrings($validator_error_messages, $lang);
Templater::setBaseDir($view_dir);
Templater::setLayoutDir($view_layout_dir);
Library::setPath($library_dir);
Helpers::setPath($helpers_dir);
Helpers::setAppPath($helpers_app_dir);
Database::setPath($drivers_dir);
StaticServer::setDir($app_dir);
Cowl::timerEnd('cowl set defaults');
Cowl::timer('cowl plugins load');
Current::$plugins = new Plugins();
Cowl::timerEnd('cowl plugins load');
// Load default helper
Helpers::load('standard', 'form');
Cowl::timerEnd('cowl init');
}
示例2: execute
/**
* Execution method always used for tasks
*
* @return void
*/
public function execute()
{
Security::setHash('sha512');
$file = Hash::get($this->args, '0');
if (!file_exists($file)) {
$this->out(__d('users', '<warning>Not found file.</warning>'));
return;
}
$user = $this->User->findById(1);
CakeSession::write(AuthComponent::$sessionKey, $user['User']);
$request = new CakeRequest();
$controller = new Controller($request);
Current::initialize($controller);
if (!$this->User->importUsers($file)) {
//バリデーションエラーの場合
//$this->NetCommons->handleValidationError($this->User->validationErrors);
$this->out(__d('users', '<error>Import error.</error>'));
$this->out(var_export($this->User->validationErrors, true));
} else {
$this->out(__d('users', '<success>Import success.</success>'));
}
}