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

Public Member Functions

 __construct (string $operation_name, string $description, string $context=ilOrgUnitOperationContext::CONTEXT_OBJECT)
 
 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 getPreconditions (Environment $environment)
 
 achieve (Environment $environment)
 
 isApplicable (Environment $environment)
 

Protected Member Functions

 doesOperationExistInContext (ilDBInterface $db, int $context_id, string $operation)
 
 getContextId (ilDBInterface $db, string $context)
 Defaults to 0 if context is not found. More...
 

Protected Attributes

string $operation_name
 
string $description
 
string $context
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitOperationRegisteredObjective::__construct ( string  $operation_name,
string  $description,
string  $context = ilOrgUnitOperationContext::CONTEXT_OBJECT 
)

Member Function Documentation

◆ achieve()

ilOrgUnitOperationRegisteredObjective::achieve ( Environment  $environment)

Definition at line 64 of file class.ilOrgUnitOperationRegisteredObjective.php.

65 {
66 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
67
68 // abort if context does not exist, just to be safe
69 if (!($context_id = $this->getContextId($db, $this->context))) {
70 throw new Exception(
71 'Context ' . $this->context . ' does not exists,
72 this objective should not be applied!'
73 );
74 }
75
76 // abort if operation already exists in this context, just to be safe
78 $db,
79 $context_id,
80 $this->operation_name
81 )) {
82 return $environment;
83 }
84
85 $id = $db->nextId('il_orgu_operations');
86 $db->insert('il_orgu_operations', [
87 'operation_id' => ['integer', $id],
88 'operation_string' => ['text', $this->operation_name],
89 'description' => ['text', $this->description],
90 'list_order' => ['integer', 0],
91 'context_id' => ['integer', $context_id],
92 ]);
93
94 return $environment;
95 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getContextId(ilDBInterface $db, string $context)
Defaults to 0 if context is not found.
doesOperationExistInContext(ilDBInterface $db, int $context_id, string $operation)
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, doesOperationExistInContext(), getContextId(), and ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ doesOperationExistInContext()

ilOrgUnitOperationRegisteredObjective::doesOperationExistInContext ( ilDBInterface  $db,
int  $context_id,
string  $operation 
)
protected

Definition at line 120 of file class.ilOrgUnitOperationRegisteredObjective.php.

124 : bool {
125 $result = $db->query('SELECT * FROM il_orgu_operations
126 WHERE context_id = ' . $db->quote($context_id, 'integer') .
127 ' AND operation_string = ' . $db->quote($operation, 'text'));
128 if ($result->numRows()) {
129 return true;
130 }
131 return false;
132 }
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.

Referenced by achieve(), and isApplicable().

+ Here is the caller graph for this function:

◆ getContextId()

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

Defaults to 0 if context is not found.

Definition at line 137 of file class.ilOrgUnitOperationRegisteredObjective.php.

140 : int {
141 $result = $db->query('SELECT id FROM il_orgu_op_contexts
142 WHERE context = ' . $db->quote($context, 'text'));
143 if (!($row = $result->fetchObject())) {
144 return 0;
145 }
146 return (int) $row->id;
147 }

Referenced by achieve(), and isApplicable().

+ Here is the caller graph for this function:

◆ getHash()

ilOrgUnitOperationRegisteredObjective::getHash ( )

Definition at line 41 of file class.ilOrgUnitOperationRegisteredObjective.php.

41 : string
42 {
43 return hash('sha256', self::class . '::' . $this->operation_name);
44 }

◆ getLabel()

ilOrgUnitOperationRegisteredObjective::getLabel ( )

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

46 : string
47 {
48 return 'Add OrgUnit operation (name=' . $this->operation_name .
49 ';context=' . $this->context . ')';
50 }

◆ getPreconditions()

ilOrgUnitOperationRegisteredObjective::getPreconditions ( Environment  $environment)

◆ isApplicable()

ilOrgUnitOperationRegisteredObjective::isApplicable ( Environment  $environment)

Definition at line 97 of file class.ilOrgUnitOperationRegisteredObjective.php.

97 : bool
98 {
99 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
100
101 // something is wrong if context does not exist
102 if (!($context_id = $this->getContextId($db, $this->context))) {
103 throw new Setup\UnachievableException(
104 'Cannot find context ' . $this->context
105 );
106 }
107
108 // not applicable if operation already exists in this context
110 $db,
111 $context_id,
112 $this->operation_name
113 )) {
114 return false;
115 }
116
117 return true;
118 }

References doesOperationExistInContext(), getContextId(), and ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ isNotable()

ilOrgUnitOperationRegisteredObjective::isNotable ( )

Definition at line 52 of file class.ilOrgUnitOperationRegisteredObjective.php.

52 : bool
53 {
54 return true;
55 }

Field Documentation

◆ $context

string ilOrgUnitOperationRegisteredObjective::$context
protected

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

Referenced by __construct().

◆ $description

string ilOrgUnitOperationRegisteredObjective::$description
protected

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

Referenced by __construct().

◆ $operation_name

string ilOrgUnitOperationRegisteredObjective::$operation_name
protected

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

Referenced by __construct().


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