19 declare(strict_types=1);
31 string $operation_name,
42 return hash(
'sha256', self::class .
'::' . $this->operation_name);
47 return 'Add OrgUnit operation (name=' . $this->operation_name .
48 ';context=' . $this->context .
')';
65 $db = $environment->
getResource(Environment::RESOURCE_DATABASE);
68 if (!($context_id = $this->
getContextId($db, $this->context))) {
70 'Context ' . $this->context .
' does not exists, 71 this objective should not be applied!' 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],
98 $db = $environment->
getResource(Environment::RESOURCE_DATABASE);
101 if (!($context_id = $this->
getContextId($db, $this->context))) {
102 throw new Setup\UnachievableException(
103 'Cannot find context ' . $this->context
111 $this->operation_name
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()) {
140 $result = $db->
query(
'SELECT id FROM il_orgu_op_contexts 141 WHERE context = ' . $db->
quote($context,
'text'));
142 if (!($row = $result->fetchObject())) {
145 return (
int) $row->id;
isApplicable(Environment $environment)
doesOperationExistInContext(ilDBInterface $db, int $context_id, string $operation)
quote($value, string $type)
getPreconditions(Environment $environment)
getContextId(ilDBInterface $db, string $context)
Defaults to 0 if context is not found.
query(string $query)
Run a (read-only) Query on the database.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(string $operation_name, string $description, string $context=ilOrgUnitOperationContext::CONTEXT_OBJECT)
An environment holds resources to be used in the setup process.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
achieve(Environment $environment)