当前位置: 首页>>代码示例>>PHP>>正文


PHP coursecat::coursecat0方法代码示例

本文整理汇总了PHP中coursecat::coursecat0方法的典型用法代码示例。如果您正苦于以下问题:PHP coursecat::coursecat0方法的具体用法?PHP coursecat::coursecat0怎么用?PHP coursecat::coursecat0使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coursecat的用法示例。


在下文中一共展示了coursecat::coursecat0方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * Returns coursecat object for requested category
  *
  * If category is not visible to user it is treated as non existing
  * unless $alwaysreturnhidden is set to true
  *
  * If id is 0, the pseudo object for root category is returned (convenient
  * for calling other functions such as get_children())
  *
  * @param int $id category id
  * @param int $strictness whether to throw an exception (MUST_EXIST) or
  *     return null (IGNORE_MISSING) in case the category is not found or
  *     not visible to current user
  * @param bool $alwaysreturnhidden set to true if you want an object to be
  *     returned even if this category is not visible to the current user
  *     (category is hidden and user does not have
  *     'moodle/category:viewhiddencategories' capability). Use with care!
  * @return null|coursecat
  * @throws moodle_exception
  */
 public static function get($id, $strictness = MUST_EXIST, $alwaysreturnhidden = false)
 {
     if (!$id) {
         if (!isset(self::$coursecat0)) {
             $record = new stdClass();
             $record->id = 0;
             $record->visible = 1;
             $record->depth = 0;
             $record->path = '';
             self::$coursecat0 = new coursecat($record);
         }
         return self::$coursecat0;
     }
     $coursecatrecordcache = cache::make('core', 'coursecatrecords');
     $coursecat = $coursecatrecordcache->get($id);
     if ($coursecat === false) {
         if ($records = self::get_records('cc.id = :id', array('id' => $id))) {
             $record = reset($records);
             $coursecat = new coursecat($record);
             // Store in cache.
             $coursecatrecordcache->set($id, $coursecat);
         }
     }
     if ($coursecat && ($alwaysreturnhidden || $coursecat->is_uservisible())) {
         return $coursecat;
     } else {
         if ($strictness == MUST_EXIST) {
             throw new moodle_exception('unknowncategory');
         }
     }
     return null;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:52,代码来源:coursecatlib.php


注:本文中的coursecat::coursecat0方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。