本文整理汇总了PHP中Storage::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::read方法的具体用法?PHP Storage::read怎么用?PHP Storage::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Storage
的用法示例。
在下文中一共展示了Storage::read方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* validate
*
* Run validation process
*
* @return null
*/
public function validate()
{
parent::validate();
// compare protection code
if (property_exists($this->_data, 'protection_code')) {
$protectionCode = \Storage::read('protection-code-register');
\Storage::remove('protection-code-register');
if ($this->_data->protection_code !== $protectionCode) {
$this->addMessage('protection_code', \View::$language->register_form_protection_code_invalid);
}
}
// compare password confirmation
if (property_exists($this->_data, 'password') && property_exists($this->_data, 'confirm_password') && $this->_data->password !== $this->_data->confirm_password) {
$this->addMessage('confirm_password', \View::$language->register_form_password_confirm_mismatch);
}
// check for existence
if ($this->isValid()) {
$checkedFields = array('email', 'login');
$UserModel = \App::getInstance('common\\UserModel');
foreach ($checkedFields as $fName) {
if ($UserModel->isExists($fName, $this->_data->{$fName})) {
$mKey = 'register_form_' . $fName . '_is_exists';
$this->addMessage($fName, \View::$language->{$mKey});
}
}
}
}
示例2: testWhatYouWriteIsReadBack
public function testWhatYouWriteIsReadBack()
{
$data = array('this' => 'is', 'a' => 'sample');
Storage::write($data);
$read = Storage::read();
$this->assertEquals($read, $data);
// Actual, Expected <-- alphabetic order
}
示例3: loadGitLabUser
/**
* load gitlab user data from file.
*
* @return type user list(json encoding)
*/
public function loadGitLabUser()
{
if (\Storage::has($this->userList)) {
$users = \Storage::read($this->userList);
return json_decode($users, true);
}
// if file not exist, create empty list.
return [];
}
示例4: html_before
/**
*html静态文件缓存
* @access protected
* @param string $filename 生成的静态文件名称
* @param string $filepath 生成的静态文件路径
* @param string $expire 静态文件缓存时间
* @return void
*/
protected function html_before($filename = '',$filepath = '',$expire = 15){
$suffix = C('HTML_FILE_SUFFIX')?C('HTML_FILE_SUFFIX'):'shtml';
if($filename === '' && $filepath === ''){
$filename = APP_PATH.'/static/'.__ACTION__.'.'.$suffix;
}else{
$filename = $filename?$filename.'.'.$suffix:md5(__ACTION__).'.'.$suffix;
$filepath = $filepath?APP_PATH.'/'.$filepath:APP_PATH.'/static';
$filename = $filepath.'/'.$filename;
}
if(Storage::has($filename)){
if(time() - Storage::get($filename,'mtime') < $expire){
exit(Storage::read($filename));
}
}
$this->filename = $filename;
}
示例5: validate
/**
* validate
*
* Run validation process
*
* @return null
*/
public function validate()
{
parent::validate();
// compare protection code
if (property_exists($this->_data, 'protection_code')) {
$protectionCode = \Storage::read('protection-code-sign-in');
\Storage::remove('protection-code-sign-in');
if ($this->_data->protection_code !== $protectionCode) {
$this->addMessage('protection_code', \View::$language->sign_in_form_protection_code_invalid);
}
}
// remove sign in counter data
if ($this->isValid()) {
\Storage::remove('sign-in-tries');
}
}
示例6: read
public function read()
{
//cached file exists?
$cache = $this->options['cacheDir'] . md5($this->options['cacheId']);
if (!file_exists($cache)) {
return null;
}
$now = time();
$timeout = $this->options['timeout'];
//read timestamp
$data = json_decode(Storage::read($cache), true);
$timestamp = $data['timestamp'];
if ($now - $timestamp <= $timeout) {
return $data['data'];
} else {
//cache expired
Storage::delete($cache);
return null;
}
}
示例7: list
<?php
require_once CONFIG::get('ABSPATH') . '/src/models/person.php';
require_once CONFIG::get('ABSPATH') . '/src/models/storage.php';
$display['page_title'] = 'People';
list($display['page_error'], $errors) = post_errors();
if ($display['page_error']) {
d_($display['page_error']);
}
if ($errors) {
d_($errors);
}
$stored_people = Storage::read() ?? [];
if (count($stored_people)) {
$display['stored_people'] = array_map(function ($item) {
return htmlspecialchars("{$item}");
}, $stored_people);
$display['people'] = array_map(function ($item) {
return $item->toHash();
}, $stored_people);
} else {
$display['stored_people'] = [];
$display['people'][] = array('firstname' => 'Jeff', 'surname' => 'Stelling');
$display['people'][] = array('firstname' => 'Chris', 'surname' => 'Kamara');
$display['people'][] = array('firstname' => 'Alex', 'surname' => 'Hammond');
$display['people'][] = array('firstname' => 'Jim', 'surname' => 'White');
$display['people'][] = array('firstname' => 'Natalie', 'surname' => 'Sawyer');
}
$display['button_OK'] = merge_params($url_string, array('action' => 'save'));
render(CONFIG::get('ABSPATH') . '/src/views/templates/people/list.php', CONFIG::get('ABSPATH') . '/src/views/layouts/flat.php');