ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 60 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

61 {
62 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
63
64 // abort if the context already exists, just to be safe
65 if ($this->doesContextExist($db, $this->context_name)) {
66 return $environment;
67 }
68
69 $parent_context_id = 0;
70 if (isset($this->parent_context)) {
71 // abort if the parent context does not exist, just to be safe
72 if (!($id = $this->getContextId($db, $this->parent_context))) {
73 throw new Exception(
74 'Parent context ' . $this->context_name . ' does not exist,
75 this objective should not be applied!'
76 );
77 }
78 $parent_context_id = $id;
79 }
80
81 $id = $db->nextId('il_orgu_op_contexts');
82 $db->insert('il_orgu_op_contexts', [
83 'id' => ['integer', $id],
84 'context' => ['text', $this->context_name],
85 'parent_context_id' => ['integer', $parent_context_id]
86 ]);
87
88 return $environment;
89 }
$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 112 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

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

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 122 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

125 : int {
126 $result = $db->query('SELECT id FROM il_orgu_op_contexts
127 WHERE context = ' . $db->quote($context, 'text'));
128 if (!($row = $result->fetchObject())) {
129 return 0;
130 }
131 return (int) $row->id;
132 }
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 37 of file class.ilOrgUnitOperationContextRegisteredObjective.php.

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

◆ getLabel()

ilOrgUnitOperationContextRegisteredObjective::getLabel ( )

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

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

◆ getPreconditions()

ilOrgUnitOperationContextRegisteredObjective::getPreconditions ( Environment  $environment)

◆ isApplicable()

ilOrgUnitOperationContextRegisteredObjective::isApplicable ( Environment  $environment)

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

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

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

+ Here is the call graph for this function:

◆ isNotable()

ilOrgUnitOperationContextRegisteredObjective::isNotable ( )

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

48 : bool
49 {
50 return true;
51 }

Field Documentation

◆ $context_name

string ilOrgUnitOperationContextRegisteredObjective::$context_name
protected

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

Referenced by __construct().

◆ $parent_context

string ilOrgUnitOperationContextRegisteredObjective::$parent_context
protected

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

Referenced by __construct().


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