ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjStudyProgrammeCache.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
14{
15 private static $instance = null; // ilObjStudyProgrammeCache
16
17 private function __construct()
18 {
19 $this->instances = array();
20 }
21
22 public static function singleton()
23 {
24 if (self::$instance === null) {
25 self::$instance = new ilObjStudyProgrammeCache();
26 }
27 return self::$instance;
28 }
29
30 protected $instances; // [ilObjStudyProgramme]
31
32 public function getInstanceByRefId($a_ref_id)
33 {
34 require_once("Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
35
36 // TODO: Maybe this should be done via obj_id instead of ref_id, since two
37 // ref_ids could point to the same object, hence leading to two instances of
38 // the same object. Since ilObjStudyProgramme is a container, it should (??)
39 // only have one ref_id...
40 if (!array_key_exists($a_ref_id, $this->instances)) {
41 $this->instances[$a_ref_id] = new ilObjStudyProgramme($a_ref_id);
42 }
43 return $this->instances[$a_ref_id];
44 }
45
46 public function addInstance(ilObjStudyProgramme $a_prg)
47 {
48 if (!$a_prg->getRefId()) {
49 throw new ilException("ilObjStudyProgrammeCache::addInstance: "
50 . "Can't add instance without ref_id.");
51 }
52 $this->instances[$a_prg->getRefId()] = $a_prg;
53 }
54
60 public function test_clear()
61 {
62 $this->instances = array();
63 }
64
65 public function test_isEmpty()
66 {
67 return count($this->instances) == 0;
68 }
69}
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
Cache for ilObjStudyProgrammes.
addInstance(ilObjStudyProgramme $a_prg)
getRefId()
get reference id @access public