ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilGlobalCacheSetupAgent.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 
5 use ILIAS\Setup;
7 use ILIAS\UI;
8 
9 class ilGlobalCacheSetupAgent implements Setup\Agent
10 {
14  protected $refinery;
15 
16  public function __construct(
18  ) {
19  $this->refinery = $refinery;
20  }
21 
25  public function hasConfig() : bool
26  {
27  return true;
28  }
29 
33  public function getConfigInput(Setup\Config $config = null) : UI\Component\Input\Field\Input
34  {
35  throw new \LogicException("Not yet implemented.");
36  }
37 
42  {
43  return $this->refinery->custom()->transformation(function ($data) {
44  $settings = new \ilGlobalCacheSettings();
45  if ($data === null || !$data["components"] || $data["service"] == "none") {
46  $settings->setActive(false);
47  } else {
48  $settings->setActive(true);
49  switch ($data["service"]) {
50  case "static":
51  $settings->setService(\ilGlobalCache::TYPE_STATIC);
52  break;
53  case "xcache":
54  $settings->setService(\ilGlobalCache::TYPE_XCACHE);
55  break;
56  case "memcached":
57  $settings->setService(\ilGlobalCache::TYPE_MEMCACHED);
58  break;
59  case "apc":
60  $settings->setService(\ilGlobalCache::TYPE_APC);
61  break;
62  default:
63  throw new \InvalidArgumentException(
64  "Unknown caching service: '{$data["service"]}'"
65  );
66  }
67  $settings->resetActivatedComponents();
68  if ($data["components"] == "all") {
69  $settings->activateAll();
70  } else {
71  foreach ($data["components"] as $cmp) {
72  $settings->addActivatedComponents($cmp);
73  }
74  }
75  }
76  return $settings;
77  });
78  }
79 
83  public function getInstallObjective(Setup\Config $config = null) : Setup\Objective
84  {
85  return new Setup\ObjectiveCollection(
86  "Complete objectives from Services/GlobalCache",
87  false,
89  );
90  }
91 
95  public function getUpdateObjective(Setup\Config $config = null) : Setup\Objective
96  {
97  return new Setup\NullObjective();
98  }
99 
103  public function getBuildArtifactObjective() : Setup\Objective
104  {
105  return new Setup\NullObjective();
106  }
107 }
Class Factory.
$data
Definition: storeScorm.php:23
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:14
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
getUpdateObjective(Setup\Config $config=null)
Builds data types.
Definition: Factory.php:19
__construct(Refinery\Factory $refinery)
getConfigInput(Setup\Config $config=null)
getInstallObjective(Setup\Config $config=null)
A transformation is a function from one datatype to another.
A configuration for the setup.
Definition: Config.php:10