ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilBackgroundTasksConfigStoredObjective.php
Go to the documentation of this file.
1 <?php
2 
22 
24 {
25  public function __construct(protected ilBackgroundTasksSetupConfig $config)
26  {
27  }
28 
29  public function getHash(): string
30  {
31  return hash("sha256", self::class);
32  }
33 
34  public function getLabel(): string
35  {
36  return "Fill ini with settings for components/ILIAS/BackgroundTasks_";
37  }
38 
39  public function isNotable(): bool
40  {
41  return false;
42  }
43 
47  public function getPreconditions(Environment $environment): array
48  {
49  return [
51  ];
52  }
53 
54  public function achieve(Environment $environment): Environment
55  {
56  $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
57 
58  if (!$ini->groupExists("background_tasks")) {
59  $ini->addGroup("background_tasks");
60  }
61 
62  $ini->setVariable("background_tasks", "concurrency", $this->config->getType());
63  $ini->setVariable("background_tasks", "number_of_concurrent_tasks", $this->config->getMaxCurrentTasks());
64 
65  if (!$ini->write()) {
66  throw new UnachievableException("Could not write ilias.ini.php");
67  }
68 
69  return $environment;
70  }
71 
75  public function isApplicable(Environment $environment): bool
76  {
77  $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
78  if (!$ini->groupExists("background_tasks")) {
79  return true;
80  }
81  if ($ini->readVariable("background_tasks", "concurrency") !== $this->config->getType()) {
82  return true;
83  }
84  return $ini->readVariable("background_tasks", "number_of_concurrent_tasks") !== $this->config->getMaxCurrentTasks();
85  }
86 }
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:30
__construct(protected ilBackgroundTasksSetupConfig $config)
achieve(Environment $environment)
Objectives can be achieved.
Signals that some goal won&#39;t be achievable by actions of the system ever.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
isNotable()
Get to know if this is an interesting objective for a human.
$ini
Definition: raiseError.php:20