ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilGlobalCacheConfigStoredObjective.php
Go to the documentation of this file.
1 <?php
2 
19 use ILIAS\Setup;
20 
21 class ilGlobalCacheConfigStoredObjective implements Setup\Objective
22 {
23  protected \ilGlobalCacheSettingsAdapter $settings;
24 
25  public function __construct(
27  ) {
28  $this->settings = $settings;
29  }
30 
31  public function getHash(): string
32  {
33  return hash("sha256", self::class);
34  }
35 
36  public function getLabel(): string
37  {
38  return "Store configuration of Services/GlobalCache";
39  }
40 
41  public function isNotable(): bool
42  {
43  return false;
44  }
45 
46  public function getPreconditions(Setup\Environment $environment): array
47  {
48  return [
50  ];
51  }
52 
53  public function achieve(Setup\Environment $environment): Setup\Environment
54  {
55  $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
56  $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
58  $repo = new ilMemcacheNodesRepository($db);
59  $repo->deleteAll();
60 
61  $memcached_nodes = $this->settings->getMemcachedNodes();
62  foreach ($memcached_nodes as $node) {
63  $repo->store($node);
64  }
65 
66  $return = $this->settings->storeToIniFile($client_ini);
67 
68  if (!$client_ini->write() || !$return) {
69  throw new Setup\UnachievableException("Could not write client.ini.php");
70  }
71 
72  return $environment;
73  }
74 
78  public function isApplicable(Setup\Environment $environment): bool
79  {
80  // The effort to check the whole ini file is too big here.
81  return true;
82  }
83 }
__construct(\ilGlobalCacheSettingsAdapter $settings)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27