ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilBackgroundTasksConfigStoredObjective Class Reference
+ Inheritance diagram for ilBackgroundTasksConfigStoredObjective:
+ Collaboration diagram for ilBackgroundTasksConfigStoredObjective:

Public Member Functions

 __construct (protected ilBackgroundTasksSetupConfig $config)
 
 getHash ()
 Get a hash for this objective. More...
 
 getLabel ()
 Get a label that describes this objective. More...
 
 isNotable ()
 Get to know if this is an interesting objective for a human. More...
 
 getPreconditions (Environment $environment)
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 
 isApplicable (Environment $environment)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBackgroundTasksConfigStoredObjective::__construct ( protected ilBackgroundTasksSetupConfig  $config)

Definition at line 25 of file class.ilBackgroundTasksConfigStoredObjective.php.

26  {
27  }

Member Function Documentation

◆ achieve()

ilBackgroundTasksConfigStoredObjective::achieve ( Environment  $environment)

Objectives can be achieved.

They might add resources to the environment when they have been achieved.

This method needs to be idempotent for a given environment. That means: if this is executed a second time, nothing new should happen. Or the other way round: if the environment already looks like desired, the objective should not take any further actions when this is called.

Exceptions

Implements ILIAS\Setup\Objective.

Definition at line 54 of file class.ilBackgroundTasksConfigStoredObjective.php.

References $ini, and ILIAS\Setup\Environment\getResource().

54  : 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  }
Signals that some goal won'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
$ini
Definition: raiseError.php:20
+ Here is the call graph for this function:

◆ getHash()

ilBackgroundTasksConfigStoredObjective::getHash ( )

Get a hash for this objective.

The hash of two objectives must be the same, if they are the same objective, with the same config on the same environment, i.e. if the one is achieved the other is achieved as well because they are the same.

Implements ILIAS\Setup\Objective.

Definition at line 29 of file class.ilBackgroundTasksConfigStoredObjective.php.

29  : string
30  {
31  return hash("sha256", self::class);
32  }

◆ getLabel()

ilBackgroundTasksConfigStoredObjective::getLabel ( )

Get a label that describes this objective.

Implements ILIAS\Setup\Objective.

Definition at line 34 of file class.ilBackgroundTasksConfigStoredObjective.php.

34  : string
35  {
36  return "Fill ini with settings for components/ILIAS/BackgroundTasks_";
37  }

◆ getPreconditions()

ilBackgroundTasksConfigStoredObjective::getPreconditions ( Environment  $environment)
Returns
[]

Implements ILIAS\Setup\Objective.

Definition at line 47 of file class.ilBackgroundTasksConfigStoredObjective.php.

47  : array
48  {
49  return [
51  ];
52  }

◆ isApplicable()

ilBackgroundTasksConfigStoredObjective::isApplicable ( Environment  $environment)

Implements ILIAS\Setup\Objective.

Definition at line 75 of file class.ilBackgroundTasksConfigStoredObjective.php.

References $ini, and ILIAS\Setup\Environment\getResource().

75  : 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  }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
$ini
Definition: raiseError.php:20
+ Here is the call graph for this function:

◆ isNotable()

ilBackgroundTasksConfigStoredObjective::isNotable ( )

Get to know if this is an interesting objective for a human.

Implements ILIAS\Setup\Objective.

Definition at line 39 of file class.ilBackgroundTasksConfigStoredObjective.php.

39  : bool
40  {
41  return false;
42  }

The documentation for this class was generated from the following file: