ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilBackgroundTasksConfigStoredObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
8{
12 protected $config;
13
14 public function __construct(
16 ) {
17 $this->config = $config;
18 }
19
20 public function getHash() : string
21 {
22 return hash("sha256", self::class);
23 }
24
25 public function getLabel() : string
26 {
27 return "Fill ini with settings for Services/BackgroundTasks";
28 }
29
30 public function isNotable() : bool
31 {
32 return false;
33 }
34
35 public function getPreconditions(Setup\Environment $environment) : array
36 {
37 return [
39 ];
40 }
41
42 public function achieve(Setup\Environment $environment) : Setup\Environment
43 {
44 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
45
46 if (!$ini->groupExists("background_tasks")) {
47 $ini->addGroup("background_tasks");
48 }
49
50 $ini->setVariable("background_tasks", "concurrency", $this->config->getType());
51 $ini->setVariable("background_tasks", "number_of_concurrent_tasks", $this->config->getMaxCurrentTasks());
52
53 if (!$ini->write()) {
54 throw new Setup\UnachievableException("Could not write ilias.ini.php");
55 }
56
57 return $environment;
58 }
59
63 public function isApplicable(Setup\Environment $environment) : bool
64 {
65 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
66
67 return
68 !$ini->groupExists("background_tasks") ||
69 $ini->readVariable("background_tasks", "concurrency") !== $this->config->getType() ||
70 $ini->readVariable("background_tasks", "number_of_concurrent_tasks") !== $this->config->getMaxCurrentTasks()
71 ;
72 }
73}
An exception for terminatinating execution or to throw for unit testing.
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:12
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:15
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4