ILIAS  release_8 Revision v8.24
ilObjStudyProgrammeCache Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilObjStudyProgrammeCache:

Public Member Functions

 getInstanceByRefId (int $ref_id)
 
 addInstance (ilObjStudyProgramme $prg)
 
 test_clear ()
 For testing purpose. More...
 
 test_isEmpty ()
 

Static Public Member Functions

static singleton ()
 

Protected Attributes

array $instances
 

Private Member Functions

 __construct ()
 

Static Private Attributes

static ilObjStudyProgrammeCache $instance = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Cache for ilObjStudyProgrammes.

Implemented as singleton.

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

Constructor & Destructor Documentation

◆ __construct()

ilObjStudyProgrammeCache::__construct ( )
private

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

36 {
37 $this->instances = array();
38 }

Member Function Documentation

◆ addInstance()

ilObjStudyProgrammeCache::addInstance ( ilObjStudyProgramme  $prg)

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

70 : void
71 {
72 if (!$prg->getRefId()) {
73 throw new ilException("ilObjStudyProgrammeCache::addInstance: Can't add instance without ref_id.");
74 }
75 $this->instances[$prg->getRefId()] = $prg;
76 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilObject\getRefId().

+ Here is the call graph for this function:

◆ getInstanceByRefId()

ilObjStudyProgrammeCache::getInstanceByRefId ( int  $ref_id)

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

49 {
50 // TODO: Maybe this should be done via obj_id instead of ref_id, since two
51 // ref_ids could point to the same object, hence leading to two instances of
52 // the same object. Since ilObjStudyProgramme is a container, it should (??)
53 // only have one ref_id...
54 if (!array_key_exists($ref_id, $this->instances)) {
56 if ($type === 'prg') {
57 $this->instances[$ref_id] = new ilObjStudyProgramme($ref_id);
58 }
59 if ($type === 'prgr') {
60 $prg_reference = new ilObjStudyProgrammeReference($ref_id, true);
61 $this->instances[$ref_id] = $prg_reference->getReferencedObject();
62 }
63 if ($type !== 'prgr' && $type !== 'prg') {
64 throw new \Exception('invalid ref_id: ' . $ref_id);
65 }
66 }
67 return $this->instances[$ref_id];
68 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
$ref_id
Definition: ltiauth.php:67
$type

References $ref_id, $type, and ilObject\_lookupType().

+ Here is the call graph for this function:

◆ singleton()

static ilObjStudyProgrammeCache::singleton ( )
static

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

41 {
42 if (self::$instance === null) {
43 self::$instance = new ilObjStudyProgrammeCache();
44 }
45 return self::$instance;
46 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static ilObjStudyProgrammeCache $instance

References $instance.

Referenced by ilObjStudyProgramme\initStudyProgrammeCache(), and ilObjStudyProgrammeCacheTest\testCreateBySingleton().

+ 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 83 of file class.ilObjStudyProgrammeCache.php.

83 : void
84 {
85 $this->instances = array();
86 }

◆ test_isEmpty()

ilObjStudyProgrammeCache::test_isEmpty ( )

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

88 : bool
89 {
90 return count($this->instances) === 0;
91 }

Field Documentation

◆ $instance

ilObjStudyProgrammeCache ilObjStudyProgrammeCache::$instance = null
staticprivate

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

Referenced by singleton().

◆ $instances

array ilObjStudyProgrammeCache::$instances
protected

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


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