本文整理汇总了PHP中Storage::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::create方法的具体用法?PHP Storage::create怎么用?PHP Storage::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Storage
的用法示例。
在下文中一共展示了Storage::create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storage
/**
* @return Storage
*/
static function storage()
{
global $argv;
try {
if (!isset($argv[1])) {
throw new StorageException("No json file in arguments", StorageException::DATA_FILE_NOT_FOUND);
}
$storage = new Storage($argv[1]);
} catch (StorageException $e) {
if ($e->getCode() == StorageException::DATA_FILE_NOT_FOUND) {
log_msg('Loader::storage >> no json file');
// User input
echo "Put your key:" . PHP_EOL;
$handle = fopen("php://stdin", "r");
$line = fgets($handle);
$_input_key = trim($line);
fclose($handle);
echo "Put your secret:" . PHP_EOL;
$handle = fopen("php://stdin", "r");
$line = fgets($handle);
$_input_secret = trim($line);
fclose($handle);
$storage = Storage::create($argv[1], $_input_key, $_input_secret);
if (!$storage) {
log_msg('Access denied to create file storage', true);
}
} else {
log_msg($e->getMessage(), true);
}
}
return $storage;
}
示例2: buildComplete
/**
* Method description
*
* More detailed method description
* @param void
* @return void
*/
function buildComplete()
{
if (!isset($this->tpl)) {
$this->tpl = $this->createTemplate();
}
if (Config::get("CACHE_STATIC_PAGES")) {
$page = Controller::getInstance()->getPage();
$cn = Controller::getInstance()->getControllerName();
$storage = Storage::create("WHTML cache");
if (!$storage->is_set($cn . "_" . $page . "_" . $this->getId())) {
$this->page_text = $this->getSrc() ? file_get_contents($this->getSrc()) : ($this->getText() ? $this->getText() : null);
$storage->set($cn . "_" . $page . "_" . $this->getId(), array("text" => $this->page_text, "cache_time" => time()));
} else {
$p = $storage->get($cn . "_" . $page . "_" . $this->getId());
$mtime = 0;
$changed = 0;
if ($this->getSrc()) {
if (fileChanged($this->getSrc(), $p['cache_time']) || Controller::getInstance()->XMLPageChanged($p['cache_time'])) {
$this->page_text = $this->getSrc() ? file_get_contents($this->getSrc()) : "";
$storage->set($cn . "_" . $page . "_" . $this->getId(), array("text" => $this->page_text, "cache_time" => time()));
} else {
$this->page_text = $p['text'];
}
} else {
$this->page_text = $this->getText();
}
}
} else {
$this->page_text = $this->getSrc() ? file_get_contents($this->getSrc()) : ($this->getText() ? $this->getText() : null);
}
parent::buildComplete();
}
示例3: init
public function init()
{
if (Config::getInstance()->language->cache_langs) {
self::$langs_cache = Storage::create('__Language::list__');
}
if (Config::getInstance()->language->cache_consts) {
self::$const_cache = Storage::create('__Language::consts__');
}
if (!isset(self::$langs_cache['__default__']) || !isset(self::$langs_cache['__list__'])) {
try {
$r = DB::query('select * from ' . self::LANGUAGE_TABLE);
} catch (DBException $e) {
if ($e->getCode() == 1146) {
throw new LanguageException('Table "' . self::LANGUAGE_TABLE . '" not exists.', 1);
}
throw $e;
}
$list = array();
for ($i = 0, $c = count($r); $i < $c; $i++) {
$cl = $r[$i];
$list[$cl['short_name']] = $cl['id'];
self::$langs_cache[$cl['short_name']] = $cl['id'];
if ($cl['default']) {
self::$langs_cache['__default__'] = $cl['id'];
}
}
self::$langs_cache['__list__'] = $list;
}
if (count(self::$langs_cache['__list__']) == 0) {
throw new LanguageException('There isn\'t langauges (rows) in table "' . self::LANGUAGE_TABLE . '"', 2);
}
if (!isset(self::$langs_cache['__default__'])) {
throw new LanguageException('Default language is not defined in table "' . self::LANGUAGE_TABLE . '"', 3);
}
self::determine();
}
示例4: create
function create($seg, $off, $name)
{
return parent::create(array('seg' => $seg, 'off' => $off, 'name' => $name));
}
示例5: save
/**
* @param array $param
* @return void
*/
public function save($sid, array $params)
{
$this->storage = Storage::create($this->getStorageName($sid), $params['time']);
unset($params['time']);
$this->storage['params'] = $params;
}
示例6: flushCache
/**
* Flushes cached groups for given user.
* Used only if acl.use and acl.cache_groups config flags are set to true values
*
* @param int id of user to flush cache
* @return null
*/
static function flushCache($user_id)
{
if (!isset($user_id) || !is_numeric($user_id)) {
throw new ACLException("Parameter 'user_id' has incorrect format");
}
if (Config::getInstance()->acl->use && Config::getInstance()->acl->cache_groups) {
Storage::create('acl_groups')->un_set($user_id);
}
}
示例7: getImgSizeCache
function getImgSizeCache($path = null)
{
$v = Storage::create("images_size");
if (($ret = $v->get($path)) !== false && ($stat = stat(Config::get("root_dir") . Config::get("IMAGES_DIR") . "/" . $path)) !== false && $stat['mtime'] <= $ret['mtime']) {
return $ret;
}
if (($ret = getImgSizeNoCache($path)) !== false) {
if (($stat = stat(Config::get("root_dir") . Config::get("IMAGES_DIR") . "/" . $path)) !== false) {
$ret['mtime'] = $stat['mtime'];
}
$v->set($path, $ret);
return $ret;
}
return false;
}
示例8: getStorage
/**
* returns storage (instantiate it if not yet).
* @param string config section to take storage config from.
* @return Storage
* @author kstep
*/
public function getStorage($section = "storage")
{
$section = (string) $section;
if (!$this->_storages[$section] && $this->_config[$section]) {
$this->_storages[$section] = Storage::create($this->_config[$section]);
}
return $this->_storages[$section];
}