ILIAS  release_8 Revision v8.24
class.ilBackgroundTasksConfigStoredObjective.php
Go to the documentation of this file.
1<?php
2
19use ILIAS\Setup;
20
22{
24
25 public function __construct(
27 ) {
28 $this->config = $config;
29 }
30
31 public function getHash(): string
32 {
33 return hash("sha256", self::class);
34 }
35
36 public function getLabel(): string
37 {
38 return "Fill ini with settings for Services/BackgroundTasks";
39 }
40
41 public function isNotable(): bool
42 {
43 return false;
44 }
45
49 public function getPreconditions(Setup\Environment $environment): array
50 {
51 return [
53 ];
54 }
55
56 public function achieve(Setup\Environment $environment): Setup\Environment
57 {
58 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
59
60 if (!$ini->groupExists("background_tasks")) {
61 $ini->addGroup("background_tasks");
62 }
63
64 $ini->setVariable("background_tasks", "concurrency", $this->config->getType());
65 $ini->setVariable("background_tasks", "number_of_concurrent_tasks", $this->config->getMaxCurrentTasks());
66
67 if (!$ini->write()) {
68 throw new Setup\UnachievableException("Could not write ilias.ini.php");
69 }
70
71 return $environment;
72 }
73
77 public function isApplicable(Setup\Environment $environment): bool
78 {
79 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
80
81 return
82 !$ini->groupExists("background_tasks") ||
83 $ini->readVariable("background_tasks", "concurrency") !== $this->config->getType() ||
84 $ini->readVariable("background_tasks", "number_of_concurrent_tasks") !== $this->config->getMaxCurrentTasks()
85 ;
86 }
87}
Signals that some goal won't be achievable by actions of the system ever.
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
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...
$ini
Definition: raiseError.php:4