本文整理汇总了PHP中CMS::cached_run方法的典型用法代码示例。如果您正苦于以下问题:PHP CMS::cached_run方法的具体用法?PHP CMS::cached_run怎么用?PHP CMS::cached_run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMS
的用法示例。
在下文中一共展示了CMS::cached_run方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
public function setup()
{
foreach (array('Dir', 'String', 'Textarea', 'HTML', 'WIKI', 'Content', 'Array', 'File', 'Image', 'Gallery', 'YesNo') as $type) {
self::register_type(strtolower($type), "CMS.Vars2.Type.{$type}");
}
//Core::load('CMS.Vars2.Init'); CMS_Vars2_Init::run();
CMS::cached_run('CMS.Vars2.Init');
}
示例2: initialize
/**
* @param array $config
*/
static function initialize($config = array())
{
self::$files_dir = './' . Core::option('files_name') . '/vars';
foreach ($config as $key => $value) {
self::${$key} = $value;
}
Core::load('CMS.Vars.Types');
if (self::$type == 'orm') {
Core::load('CMS.Vars.ORM');
WS::env()->orm->submapper('vars', 'CMS.Vars.ORM.Mapper');
}
if (self::$type == 'storage') {
Core::load('Storage');
Storage::manager()->add('vars', 'CMS.Vars.Storage');
}
CMS::cached_run('CMS.Vars.Schema');
self::register_type('CMS.Vars.Types.Dir', 'CMS.Vars.Types.Integer', 'CMS.Vars.Types.String', 'CMS.Vars.Types.Text', 'CMS.Vars.Types.Html', 'CMS.Vars.Types.Array', 'CMS.Vars.Types.Mail', 'CMS.Vars.Types.HtmlP', 'CMS.Vars.Types.File');
CMS_Dumps::dumper('VARS', 'CMS.Dumps.Vars');
}
示例3: process_schema
public function process_schema()
{
// process schema modules
$modules = $this->schema_modules();
if (!empty($modules)) {
foreach ($modules as $name => $module) {
CMS::cached_run($module);
}
}
// get data from config
$schema = $this->config('schema');
$fields = $this->config('fields');
$tmp1 = (array) $schema;
$tmp2 = (array) $fields;
if (empty($tmp1) && empty($tmp2)) {
return;
}
if (empty($fields)) {
$fields = Core::hash();
}
$schema = clone $schema;
// some time we have fields without info in schema
// fix it
$schema_keys = array_keys((array) $schema);
$fields_keys = array_keys((array) $fields);
$diff = array_diff($fields_keys, $schema_keys);
foreach ($diff as $name) {
$schema->{$name} = array();
}
//fields to schema
Core::load('DB.Schema');
Core::load('CMS.Fields');
foreach ($schema as $name => &$table) {
if (!empty($fields->{$name})) {
$table_fields = $fields->{$name};
$table_name = $name;
CMS_Fields::fields_to_schema($fields->{$name}, $name, $table);
Events::add_once('db.schema.after_execute.' . $name, function ($tf_schema) use($table_fields, $table_name) {
foreach ($table_fields as $tf_name => $tf_data) {
$tf_type = CMS_Fields::type($tf_data);
$tf_type->process_schema($tf_name, $tf_data, $table_name, $table_fields);
}
});
}
}
// remove empty values
foreach ($schema as $name => $ttable) {
if (empty($ttable)) {
unset($schema->{$name});
}
}
// cache
$cname = strtolower($this->get_name());
if (!empty($cname)) {
$cache_key = 'cms:component:' . $cname . ':schema:' . md5(serialize($schema));
if ($this->cache->has($cache_key)) {
return $this;
}
$this->cache->set($cache_key, 1, 0);
}
// run
DB_Schema::process_cache($schema);
}
示例4: get_call_time
static function get_call_time($name)
{
static $schema_checked = false;
if (!$schema_checked) {
CMS::cached_run('CMS.Schema.CLI');
$schema_checked = true;
}
$row = CMS::orm()->connection->prepare('SELECT * FROM tao_cli_calls WHERE name=:name ORDER BY time desc LIMIT 1')->bind(array('name' => $name))->execute()->fetch();
if (!$row) {
return 0;
}
return $row['time'];
}