ILIAS  release_7 Revision v7.30-3-g800a261c036
CollectedObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2020 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5namespace ILIAS\Setup\Metrics;
6
8
12abstract class CollectedObjective implements Setup\Objective
13{
17 protected $storage;
18
19 public function __construct(Storage $storage)
20 {
21 $this->storage = $storage;
22 }
23
33 abstract protected function collectFrom(Setup\Environment $environment, Storage $storage) : void;
34
44 abstract protected function getTentativePreconditions(Setup\Environment $environment) : array;
45
46 public function getHash() : string
47 {
48 return hash("sha256", static::class);
49 }
50
51 public function getLabel() : string
52 {
53 return "Collect metrics.";
54 }
55
56 public function isNotable() : bool
57 {
58 return false;
59 }
60
61 public function getPreconditions(Setup\Environment $environment) : array
62 {
63 return array_map(
64 function (Setup\Objective $o) {
65 return new Setup\Objective\Tentatively($o);
66 },
67 $this->getTentativePreconditions($environment)
68 );
69 }
70
71 public function achieve(Setup\Environment $environment) : Setup\Environment
72 {
73 $this->collectFrom($environment, $this->storage);
74 return $environment;
75 }
76
80 public function isApplicable(Setup\Environment $environment) : bool
81 {
82 // We want to always collect fresh metrics.
83 return true;
84 }
85}
An exception for terminatinating execution or to throw for unit testing.
Base class to simplify collection of metrics.
isApplicable(Setup\Environment $environment)
@inheritDoc
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:14
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...