當前位置: 首頁>>代碼示例>>PHP>>正文


PHP context::cache_add方法代碼示例

本文整理匯總了PHP中context::cache_add方法的典型用法代碼示例。如果您正苦於以下問題:PHP context::cache_add方法的具體用法?PHP context::cache_add怎麽用?PHP context::cache_add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在context的用法示例。


在下文中一共展示了context::cache_add方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_from_record

 public static function get_from_record($record)
 {
     if ($context = context::cache_get(CONTEXT_COURSE, $record->id)) {
         return $context;
     }
     $context = new context_course($record);
     context::cache_add($context);
     return $context;
 }
開發者ID:CTANZ,項目名稱:moodle-mod_equella,代碼行數:9,代碼來源:locallib.php

示例2: instance

 /**
  * Returns block context instance.
  *
  * @static
  * @param int $instanceid
  * @param int $strictness
  * @return context_block context instance
  */
 public static function instance($instanceid, $strictness = MUST_EXIST)
 {
     global $DB;
     if ($context = context::cache_get(CONTEXT_BLOCK, $instanceid)) {
         return $context;
     }
     if (!($record = $DB->get_record('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $instanceid)))) {
         if ($bi = $DB->get_record('block_instances', array('id' => $instanceid), 'id,parentcontextid', $strictness)) {
             $parentcontext = context::instance_by_id($bi->parentcontextid);
             $record = context::insert_context_record(CONTEXT_BLOCK, $bi->id, $parentcontext->path);
         }
     }
     if ($record) {
         $context = new context_block($record);
         context::cache_add($context);
         return $context;
     }
     return false;
 }
開發者ID:rolandovanegas,項目名稱:moodle,代碼行數:27,代碼來源:accesslib.php

示例3: instance

    /**
     * Returns costcenter context instance.
     *
     * @static
     * @param int $instanceid
     * @param int $strictness
     * @return context_costcenter context instance
     */
    public static function instance($instanceid, $strictness = MUST_EXIST) {
        global $DB;

        if ($context = context::cache_get(CONTEXT_COSTCENTER, $instanceid)) {
            return $context;
        }

        if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_COSTCENTER, 'instanceid' => $instanceid))) {
            if ($costcenter = $DB->get_record('local_costcenter', array('id' => $instanceid), 'id,parentid', $strictness)) {
                if ($costcenter->parentid) {
                    $parentcontext = context_costcenter::instance($costcenter->parentid);
                    $record = context::insert_context_record(CONTEXT_COSTCENTER, $costcenter->id, $parentcontext->path);
                } else {
                    $record = context::insert_context_record(CONTEXT_COSTCENTER, $costcenter->id, '/' . SYSCONTEXTID, 0);
                }
            }
        }

        if ($record) {
            $context = new context_costcenter($record);
            context::cache_add($context);
            return $context;
        }

        return false;
    }
開發者ID:narasimhaeabyas,項目名稱:tataaiapro,代碼行數:34,代碼來源:accesslib.php


注:本文中的context::cache_add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。