ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilNICKeyStoredObjective.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{
9 public function getHash() : string
10 {
11 return hash("sha256", self::class);
12 }
13
14 public function getLabel() : string
15 {
16 return "A NIC key for the installation is generated and stored";
17 }
18
19 public function isNotable() : bool
20 {
21 return true;
22 }
23
24 public function getPreconditions(Setup\Environment $environment) : array
25 {
26 return [
27 new \ilSettingsFactoryExistsObjective()
28 ];
29 }
30
31 public function achieve(Setup\Environment $environment) : Setup\Environment
32 {
33 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
34 $settings = $factory->settingsFor("common");
35
36 $nic_key = $this->generateNICKey();
37 $settings->set("nic_key", $nic_key);
38
39 return $environment;
40 }
41
45 public function isApplicable(Setup\Environment $environment) : bool
46 {
47 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
48 $settings = $factory->settingsFor("common");
49
50 return !(bool) $settings->get("nic_key");
51 }
52
53 protected function generateNICKey()
54 {
55 return md5(uniqid($this->getClientId(), true));
56 }
57}
An exception for terminatinating execution or to throw for unit testing.
getPreconditions(Setup\Environment $environment)
isApplicable(Setup\Environment $environment)
@inheritDoc
achieve(Setup\Environment $environment)
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
$factory
Definition: metadata.php:58
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...