本文整理汇总了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>'));
}
}