ILIAS  release_8 Revision v8.24
class.ilGlobalCacheSetupAgent.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
25
27{
28 protected \ILIAS\Refinery\Factory $refinery;
29
30
31 public function __construct(
32 Refinery\Factory $refinery
33 ) {
34 $this->refinery = $refinery;
35 }
36
40 public function hasConfig(): bool
41 {
42 return true;
43 }
44
49 {
50 return $this->refinery->custom()->transformation(function ($data): \ilGlobalCacheSettings {
51 $settings = new \ilGlobalCacheSettings();
52 if (
53 $data === null ||
54 !isset($data["components"]) ||
55 !$data["components"] ||
56 !isset($data["service"]) ||
57 $data["service"] === "none" ||
58 (
59 $data["service"] === "memcached" &&
60 (!isset($data["memcached_nodes"]) || count($data["memcached_nodes"]) === 0)
61 )
62 ) {
63 $settings->setActive(false);
64 } else {
65 $settings->setActive(true);
66 switch ($data["service"]) {
67 case "xcache": // xcache has been removed in ILIAS 8, we switch to static cache then
68 case "static":
70 break;
71 case "memcached":
72 array_walk($data["memcached_nodes"], function (array $node) use ($settings): void {
73 $settings->addMemcachedNode($this->getMemcachedServer($node));
74 });
76 break;
77 case "apc":
79 break;
80 default:
81 throw new \InvalidArgumentException(
82 sprintf("Unknown caching service: '%s'", $data["service"])
83 );
84 }
85 $settings->resetActivatedComponents();
86 if ($data["components"] === "all") {
87 $settings->activateAll();
88 } else {
89 foreach ($data["components"] as $cmp => $active) {
90 if ($active) {
91 $settings->addActivatedComponent($cmp);
92 }
93 }
94 }
95 }
96
97 return $settings;
98 });
99 }
100
101 protected function getMemcachedServer(array $node): ilMemcacheServer
102 {
103 $m = new ilMemcacheServer();
104 $m->setStatus(boolval($node["active"]) === true ? ilMemcacheServer::STATUS_ACTIVE : ilMemcacheServer::STATUS_INACTIVE);
105 $m->setHost((string) $node["host"]);
106 $m->setPort((int) $node["port"]);
107 $m->setWeight((int) $node["weight"]);
108
109 return $m;
110 }
111
115 public function getInstallObjective(Setup\Config $config = null): Setup\Objective
116 {
117 if (!$config instanceof ilGlobalCacheSettings) {
118 throw new Setup\UnachievableException('wrong config type, expected ilGlobalCacheSettings');
119 }
121 }
122
126 public function getUpdateObjective(Setup\Config $config = null): Setup\Objective
127 {
128 if ($config instanceof ilGlobalCacheSettings) {
130 }
132 }
133
137 public function getBuildArtifactObjective(): Setup\Objective
138 {
140 }
141
145 public function getStatusObjective(Setup\Metrics\Storage $storage): Setup\Objective
146 {
147 return new ilGlobalCacheMetricsCollectedObjective($storage);
148 }
149
153 public function getMigrations(): array
154 {
155 return [];
156 }
157
158 public function getNamedObjectives(?Config $config = null): array
159 {
160 return [
161 'flushAll' => new ObjectiveConstructor(
162 'flushes all GlobalCaches.',
163 function () {
165 }
166 )
167 ];
168 }
169}
Builds data types.
Definition: Factory.php:21
A non-objective, nothing to do to achieve it...
Signals that some goal won't be achievable by actions of the system ever.
Class ilGlobalCacheSettings.
getUpdateObjective(Setup\Config $config=null)
getStatusObjective(Setup\Metrics\Storage $storage)
getInstallObjective(Setup\Config $config=null)
__construct(Refinery\Factory $refinery)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A transformation is a function from one datatype to another.
A agent is some component that performs part of the setup process.
Definition: Agent.php:30
A configuration for the setup.
Definition: Config.php:27
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
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...
Definition: ByTrying.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...