ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ilOrgUnitOperationContextRegisteredObjective Class Reference
+ Inheritance diagram for ilOrgUnitOperationContextRegisteredObjective:
+ Collaboration diagram for ilOrgUnitOperationContextRegisteredObjective:

Public Member Functions

 __construct (string $context_name, ?string $parent_context=null)
 
 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 getPreconditions (Environment $environment)
 
 achieve (Environment $environment)
 
 isApplicable (Environment $environment)
 

Protected Member Functions

 doesContextExist (ilDBInterface $db, string $context)
 
 getContextId (ilDBInterface $db, string $context)
 Defaults to 0 if context is not found. More...
 

Protected Attributes

string $context_name
 
string $parent_context
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitOperationContextRegisteredObjective::__construct ( string  $context_name,
?string  $parent_context = null 
)

Member Function Documentation

◆ achieve()

ilOrgUnitOperationContextRegisteredObjective::achieve ( Environment  $environment)

Definition at line 61 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

62 {
63 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
64
65 // abort if the context already exists, just to be safe
66 if ($this->doesContextExist($db, $this->context_name)) {
67 return $environment;
68 }
69
70 $parent_context_id = 0;
71 if (isset($this->parent_context)) {
72 // abort if the parent context does not exist, just to be safe
73 if (!($id = $this->getContextId($db, $this->parent_context))) {
74 throw new Exception(
75 'Parent context ' . $this->context_name . ' does not exist,
76 this objective should not be applied!'
77 );
78 }
79 $parent_context_id = $id;
80 }
81
82 $id = $db->nextId('il_orgu_op_contexts');
83 $db->insert('il_orgu_op_contexts', [
84 'id' => ['integer', $id],
85 'context' => ['text', $this->context_name],
86 'parent_context_id' => ['integer', $parent_context_id]
87 ]);
88
89 return $environment;
90 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getContextId(ilDBInterface $db, string $context)
Defaults to 0 if context is not found.
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.

References $id, doesContextExist(), getContextId(), and ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ doesContextExist()

ilOrgUnitOperationContextRegisteredObjective::doesContextExist ( ilDBInterface  $db,
string  $context 
)
protected

Definition at line 113 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

116 : bool {
117 return (bool) $this->getContextId($db, $context);
118 }
$context
Definition: webdav.php:29

Referenced by achieve(), and isApplicable().

+ Here is the caller graph for this function:

◆ getContextId()

ilOrgUnitOperationContextRegisteredObjective::getContextId ( ilDBInterface  $db,
string  $context 
)
protected

Defaults to 0 if context is not found.

Definition at line 123 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

126 : int {
127 $result = $db->query('SELECT id FROM il_orgu_op_contexts
128 WHERE context = ' . $db->quote($context, 'text'));
129 if (!($row = $result->fetchObject())) {
130 return 0;
131 }
132 return (int) $row->id;
133 }
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.

Referenced by achieve().

+ Here is the caller graph for this function:

◆ getHash()

ilOrgUnitOperationContextRegisteredObjective::getHash ( )

Definition at line 38 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

38 : string
39 {
40 return hash('sha256', self::class . '::' . $this->context_name);
41 }

◆ getLabel()

ilOrgUnitOperationContextRegisteredObjective::getLabel ( )

Definition at line 43 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

43 : string
44 {
45 return 'Add OrgUnit operation context (name=' . $this->context_name .
46 ';parent_context=' . $this->parent_context . ')';
47 }

◆ getPreconditions()

ilOrgUnitOperationContextRegisteredObjective::getPreconditions ( Environment  $environment)

◆ isApplicable()

ilOrgUnitOperationContextRegisteredObjective::isApplicable ( Environment  $environment)

Definition at line 92 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

92 : bool
93 {
94 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
95
96 // not applicable if the context already exists
97 if ($this->doesContextExist($db, $this->context_name)) {
98 return false;
99 }
100
101 if (isset($this->parent_context)) {
102 // something is wrong if the parent context does not exist
103 if (!$this->doesContextExist($db, $this->parent_context)) {
104 throw new Exception(
105 'Cannot find parent context ' . $this->parent_context
106 );
107 }
108 }
109
110 return true;
111 }

References doesContextExist(), and ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ isNotable()

ilOrgUnitOperationContextRegisteredObjective::isNotable ( )

Definition at line 49 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

49 : bool
50 {
51 return true;
52 }

Field Documentation

◆ $context_name

string ilOrgUnitOperationContextRegisteredObjective::$context_name
protected

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

Referenced by __construct().

◆ $parent_context

string ilOrgUnitOperationContextRegisteredObjective::$parent_context
protected

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

Referenced by __construct().


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