Elgg  Version 6.1
InternalContainer.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Di;
4 
5 use Elgg\Config;
10 
128 
138  public function initConfig(Config $config): Config {
139  $this->timer->begin([]);
140 
141  if (!$config->dataroot && !$config->installer_running) {
142  throw new ConfigurationException('Config value "dataroot" is required.');
143  }
144 
145  if (!$config->cacheroot) {
146  $config->cacheroot = $config->dataroot . 'caches';
147  }
148 
149  if (!$config->assetroot) {
150  $config->assetroot = $config->cacheroot . 'views_simplecache';
151  }
152 
153  if (!$config->wwwroot) {
154  $config->wwwroot = $this->request->sniffElggUrl();
155  }
156 
157  if (!$config->plugins_path) {
158  $config->plugins_path = Paths::project() . 'mod';
159  }
160 
161  // move sensitive credentials into isolated services
162  $this->set('dbConfig', DbConfig::fromElggConfig($config));
163 
164  // get this stuff out of config!
165  foreach ($config::SENSITIVE_PROPERTIES as $name) {
166  unset($config->{$name});
167  }
168 
169  return $config;
170  }
171 
175  public static function factory(array $options = []) {
176  $container = parent::factory();
177 
178  if (isset($options['config'])) {
179  $config = $options['config'];
180  $container->set('config', function(ContainerInterface $c) use ($config) {
181  return $c->initConfig($config);
182  });
183  }
184 
185  return $container;
186  }
187 
191  public static function getDefinitionSources(): array {
192  return [\Elgg\Project\Paths::elgg() . 'engine/internal_services.php'];
193  }
194 }
static project()
Get the project root (where composer is installed) path with "/".
Definition: Paths.php:25
A generic parent class for Configuration exceptions.
static elgg()
Get the Elgg codebase path with "/".
Definition: Paths.php:44
static fromElggConfig(Config $config)
Construct from an Elgg Config.
Definition: DbConfig.php:85
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
Base DI Container class.
Definition: DiContainer.php:13
static factory(array $options=[])
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
Definition: language.php:20
initConfig(Config $config)
Validate, normalize, fill in missing values, and lock some.
$container
Definition: delete.php:23