ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 static private $instance = null; // ilObjStudyProgrammeCache
15
16 private function __construct() {
17 $this->instances = array();
18 }
19
20 static public function singleton() {
21 if (self::$instance === null) {
22 self::$instance = new ilObjStudyProgrammeCache();
23 }
24 return self::$instance;
25 }
26
27 protected $instances; // [ilObjStudyProgramme]
28
29 public function getInstanceByRefId($a_ref_id) {
30 require_once("Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
31
32 // TODO: Maybe this should be done via obj_id instead of ref_id, since two
33 // ref_ids could point to the same object, hence leading to two instances of
34 // the same object. Since ilObjStudyProgramme is a container, it should (??)
35 // only have one ref_id...
36 if (!array_key_exists($a_ref_id, $this->instances)) {
37 $this->instances[$a_ref_id] = new ilObjStudyProgramme($a_ref_id);
38 }
39 return $this->instances[$a_ref_id];
40 }
41
42 public function addInstance(ilObjStudyProgramme $a_prg) {
43 if (!$a_prg->getRefId()) {
44 throw new ilException("ilObjStudyProgrammeCache::addInstance: "
45 ."Can't add instance without ref_id.");
46 }
47 $this->instances[$a_prg->getRefId()] = $a_prg;
48 }
49
55 public function test_clear() {
56 $this->instances = array();
57 }
58
59 public function test_isEmpty() {
60 return count($this->instances) == 0;
61 }
62}
63
64?>
Base class for ILIAS Exception handling.
Cache for ilObjStudyProgrammes.
addInstance(ilObjStudyProgramme $a_prg)
Class ilObjStudyProgramme.
getRefId()
get reference id @access public