ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilNICKeyStoredObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
24{
25 public function getHash(): string
26 {
27 return hash("sha256", self::class);
28 }
29
30 public function getLabel(): string
31 {
32 return "A NIC key for the installation is generated and stored";
33 }
34
35 public function isNotable(): bool
36 {
37 return true;
38 }
39
40 public function getPreconditions(Setup\Environment $environment): array
41 {
42 return [
43 new \ilSettingsFactoryExistsObjective(),
44 new ilInstIdDefaultStoredObjective($this->config)
45 ];
46 }
47
48 public function achieve(Setup\Environment $environment): Setup\Environment
49 {
50 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
51 $settings = $factory->settingsFor("common");
52
53 $nic_key = $this->generateNICKey();
54 $settings->set("nic_key", $nic_key);
55
56 return $environment;
57 }
58
62 public function isApplicable(Setup\Environment $environment): bool
63 {
64 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
65 $settings = $factory->settingsFor("common");
66
67 return !(bool) $settings->get("nic_key");
68 }
69
70 protected function generateNICKey()
71 {
72 return md5(uniqid((string) $this->config->getClientId(), true));
73 }
74}
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:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...