ILIAS  release_8 Revision v8.24
class.ilNICKeyStoredObjective.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
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 ];
45 }
46
47 public function achieve(Setup\Environment $environment): Setup\Environment
48 {
49 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
50 $settings = $factory->settingsFor("common");
51
52 $nic_key = $this->generateNICKey();
53 $settings->set("nic_key", $nic_key);
54
55 return $environment;
56 }
57
61 public function isApplicable(Setup\Environment $environment): bool
62 {
63 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
64 $settings = $factory->settingsFor("common");
65
66 return !(bool) $settings->get("nic_key");
67 }
68
69 protected function generateNICKey()
70 {
71 return md5(uniqid((string) $this->getClientId(), true));
72 }
73}
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
$factory
Definition: metadata.php:75
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...