ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 17 of file class.ilObjStudyProgrammeCache.php.

18  {
19  $this->instances = array();
20  }

Member Function Documentation

◆ addInstance()

ilObjStudyProgrammeCache::addInstance ( ilObjStudyProgramme  $a_prg)

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

References ilObject\getRefId().

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  }
getRefId()
get reference id public
+ Here is the call graph for this function:

◆ getInstanceByRefId()

ilObjStudyProgrammeCache::getInstanceByRefId (   $a_ref_id)

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

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

◆ singleton()

static ilObjStudyProgrammeCache::singleton ( )
static

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

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

23  {
24  if (self::$instance === null) {
25  self::$instance = new ilObjStudyProgrammeCache();
26  }
27  return self::$instance;
28  }
Cache for ilObjStudyProgrammes.
+ 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 60 of file class.ilObjStudyProgrammeCache.php.

61  {
62  $this->instances = array();
63  }

◆ test_isEmpty()

ilObjStudyProgrammeCache::test_isEmpty ( )

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

66  {
67  return count($this->instances) == 0;
68  }

Field Documentation

◆ $instance

ilObjStudyProgrammeCache::$instance = null
staticprivate

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

◆ $instances

ilObjStudyProgrammeCache::$instances
protected

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


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