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

64 {
65 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
66
67 // abort if context does not exist, just to be safe
68 if (!($context_id = $this->getContextId($db, $this->context))) {
69 throw new Exception(
70 'Context ' . $this->context . ' does not exists,
71 this objective should not be applied!'
72 );
73 }
74
75 // abort if operation already exists in this context, just to be safe
77 $db,
78 $context_id,
79 $this->operation_name
80 )) {
81 return $environment;
82 }
83
84 $id = $db->nextId('il_orgu_operations');
85 $db->insert('il_orgu_operations', [
86 'operation_id' => ['integer', $id],
87 'operation_string' => ['text', $this->operation_name],
88 'description' => ['text', $this->description],
89 'list_order' => ['integer', 0],
90 'context_id' => ['integer', $context_id],
91 ]);
92
93 return $environment;
94 }
$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 119 of file class.ilOrgUnitOperationRegisteredObjective.php.

123 : bool {
124 $result = $db->query('SELECT * FROM il_orgu_operations
125 WHERE context_id = ' . $db->quote($context_id, 'integer') .
126 ' AND operation_string = ' . $db->quote($operation, 'text'));
127 if ($result->numRows()) {
128 return true;
129 }
130 return false;
131 }
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 136 of file class.ilOrgUnitOperationRegisteredObjective.php.

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

Referenced by achieve(), and isApplicable().

+ Here is the caller graph for this function:

◆ getHash()

ilOrgUnitOperationRegisteredObjective::getHash ( )

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

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

◆ getLabel()

ilOrgUnitOperationRegisteredObjective::getLabel ( )

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

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

◆ getPreconditions()

ilOrgUnitOperationRegisteredObjective::getPreconditions ( Environment  $environment)

◆ isApplicable()

ilOrgUnitOperationRegisteredObjective::isApplicable ( Environment  $environment)

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

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

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

+ Here is the call graph for this function:

◆ isNotable()

ilOrgUnitOperationRegisteredObjective::isNotable ( )

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

51 : bool
52 {
53 return true;
54 }

Field Documentation

◆ $context

string ilOrgUnitOperationRegisteredObjective::$context
protected

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

Referenced by __construct().

◆ $description

string ilOrgUnitOperationRegisteredObjective::$description
protected

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

Referenced by __construct().

◆ $operation_name

string ilOrgUnitOperationRegisteredObjective::$operation_name
protected

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

Referenced by __construct().


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