ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ArrayEnvironment.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Setup;
22
23use ILIAS\Setup;
24
26{
30 protected array $resources;
31
35 protected array $configs;
36
37 public function __construct(array $resources)
38 {
39 $this->resources = $resources;
40 }
41
45 public function getResource(string $id)
46 {
47 if (!isset($this->resources[$id])) {
48 return null;
49 }
50 return $this->resources[$id];
51 }
52
56 public function withResource(string $id, $resource): Environment
57 {
58 if (isset($this->resources[$id])) {
59 throw new \RuntimeException(
60 "Resource '$id' is already contained in the environment"
61 );
62 }
63 $clone = clone $this;
64 $clone->resources[$id] = $resource;
65 return $clone;
66 }
67
71 public function withConfigFor(string $component, $config): Environment
72 {
73 if (isset($this->configs[$component])) {
74 throw new \RuntimeException(
75 "Config for '$component' is already contained in the environment"
76 );
77 }
78 $clone = clone $this;
79 $clone->configs[$component] = $config;
80 return $clone;
81 }
82
86 public function getConfigFor(string $component)
87 {
88 if (!isset($this->configs[$component])) {
89 throw new \RuntimeException(
90 "Config for '$component' is not contained in the environment"
91 );
92 }
93 return $this->configs[$component];
94 }
95
99 public function hasConfigFor(string $component): bool
100 {
101 return isset($this->configs[$component]);
102 }
103}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
withResource(string $id, $resource)
RuntimeException if this resource is already in the environment.
withConfigFor(string $component, $config)
Stores a config for some component in the environment.RuntimeException if this config is already in t...
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.implements some known in...
hasConfigFor(string $component)
getConfigFor(string $component)
RuntimeException if there is no config for the component mixed
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...