ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CollectedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Setup\Metrics;
22
23use ILIAS\Setup;
24
28abstract class CollectedObjective implements Setup\Objective
29{
30 protected Storage $storage;
31
32 public function __construct(Storage $storage)
33 {
34 $this->storage = $storage;
35 }
36
46 abstract protected function collectFrom(Setup\Environment $environment, Storage $storage): void;
47
57 abstract protected function getTentativePreconditions(Setup\Environment $environment): array;
58
59 public function getHash(): string
60 {
61 return hash("sha256", static::class);
62 }
63
64 public function getLabel(): string
65 {
66 return "Collect metrics: " . get_class($this);
67 }
68
69 public function isNotable(): bool
70 {
71 return false;
72 }
73
74 public function getPreconditions(Setup\Environment $environment): array
75 {
76 return array_map(
78 $this->getTentativePreconditions($environment)
79 );
80 }
81
82 public function achieve(Setup\Environment $environment): Setup\Environment
83 {
84 $this->collectFrom($environment, $this->storage);
85 return $environment;
86 }
87
88 public function isApplicable(Setup\Environment $environment): bool
89 {
90 // We want to always collect fresh metrics.
91 return true;
92 }
93}
Base class to simplify collection of metrics.
isApplicable(Setup\Environment $environment)
achieve(Setup\Environment $environment)
getHash()
Get a hash for this objective.
getTentativePreconditions(Setup\Environment $environment)
Give preconditions that might or might not be fullfilled.
getLabel()
Get a label that describes this objective.
getPreconditions(Setup\Environment $environment)
collectFrom(Setup\Environment $environment, Storage $storage)
Attempt to gather metrics based on the provided environment.
isNotable()
Get to know if this is an interesting objective for a human.
A wrapper around an objective that attempts to achieve the wrapped objective but won't stop the proce...
Definition: Tentatively.php:30
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...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.