ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAccessRBACOperationOrderUpdatedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
23
25{
26 protected string $operation;
27 protected int $pos;
28
29 public function __construct(string $operation, int $pos)
30 {
31 $this->operation = $operation;
32 $this->pos = $pos;
33 }
34
35 public function getHash(): string
36 {
37 return hash("sha256", self::class);
38 }
39
40 public function getLabel(): string
41 {
42 return "Update operation order (operation=$this->operation;pos=$this->pos)";
43 }
44
45 public function isNotable(): bool
46 {
47 return true;
48 }
49
50 public function getPreconditions(Environment $environment): array
51 {
52 return [
54 ];
55 }
56
57 public function achieve(Environment $environment): Environment
58 {
59 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
60
61 $db->update(
62 'rbac_operations',
63 ['op_order' => ["integer", $this->pos]],
64 ["operation" => ["text", $this->operation]]
65 );
66
67 return $environment;
68 }
69
70 public function isApplicable(Environment $environment): bool
71 {
72 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
73
74 $sql =
75 "SELECT ops_id" . PHP_EOL
76 . "FROM rbac_operations" . PHP_EOL
77 . "WHERE operation = " . $db->quote($this->operation, "text") . PHP_EOL
78 ;
79
80 return $db->numRows($db->query($sql)) == 1;
81 }
82}
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.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...