ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjStudyProgrammeCache Class Reference

Cache for ilObjStudyProgrammes. More...

+ Collaboration diagram for ilObjStudyProgrammeCache:

Public Member Functions

 getInstanceByRefId ($a_ref_id)
 
 addInstance (ilObjStudyProgramme $a_prg)
 
 test_clear ()
 For testing purpose. More...
 
 test_isEmpty ()
 

Static Public Member Functions

static singleton ()
 

Protected Attributes

 $instances
 

Private Member Functions

 __construct ()
 

Static Private Attributes

static $instance = null
 

Detailed Description

Cache for ilObjStudyProgrammes.

Implemented as singleton.

Author
: Richard Klees richa.nosp@m.rd.k.nosp@m.lees@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de

Definition at line 13 of file class.ilObjStudyProgrammeCache.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjStudyProgrammeCache::__construct ( )
private

Definition at line 16 of file class.ilObjStudyProgrammeCache.php.

16 {
17 $this->instances = array();
18 }

Member Function Documentation

◆ addInstance()

ilObjStudyProgrammeCache::addInstance ( ilObjStudyProgramme  $a_prg)

Definition at line 42 of file class.ilObjStudyProgrammeCache.php.

42 {
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 }
Base class for ILIAS Exception handling.
getRefId()
get reference id @access public

References ilObject\getRefId().

+ Here is the call graph for this function:

◆ getInstanceByRefId()

ilObjStudyProgrammeCache::getInstanceByRefId (   $a_ref_id)

Definition at line 29 of file class.ilObjStudyProgrammeCache.php.

29 {
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 }
Class ilObjStudyProgramme.

◆ singleton()

static ilObjStudyProgrammeCache::singleton ( )
static

Definition at line 20 of file class.ilObjStudyProgrammeCache.php.

20 {
21 if (self::$instance === null) {
22 self::$instance = new ilObjStudyProgrammeCache();
23 }
24 return self::$instance;
25 }
Cache for ilObjStudyProgrammes.

References $instance.

Referenced by ilObjStudyProgramme\initStudyProgrammeCache(), and ilObjStudyProgrammeTest\testGetInstanceByRefId().

+ Here is the caller graph for this function:

◆ test_clear()

ilObjStudyProgrammeCache::test_clear ( )

For testing purpose.

TODO: Move to mock class in tests.

Definition at line 55 of file class.ilObjStudyProgrammeCache.php.

55 {
56 $this->instances = array();
57 }

◆ test_isEmpty()

ilObjStudyProgrammeCache::test_isEmpty ( )

Definition at line 59 of file class.ilObjStudyProgrammeCache.php.

59 {
60 return count($this->instances) == 0;
61 }

Field Documentation

◆ $instance

ilObjStudyProgrammeCache::$instance = null
staticprivate

Definition at line 14 of file class.ilObjStudyProgrammeCache.php.

Referenced by singleton().

◆ $instances

ilObjStudyProgrammeCache::$instances
protected

Definition at line 27 of file class.ilObjStudyProgrammeCache.php.


The documentation for this class was generated from the following file: