Elgg  Version 4.3
configuration.php
Go to the documentation of this file.
1 <?php
19 
26 function elgg_get_site_url() {
27  return _elgg_services()->config->wwwroot;
28 }
29 
37  return _elgg_services()->plugins->getPath();
38 }
39 
46 function elgg_get_data_path() {
47  return _elgg_services()->config->dataroot;
48 }
49 
57 function elgg_get_cache_path() {
58  $path = _elgg_services()->config->cacheroot ? : elgg_get_data_path() . 'caches/';
59  return Paths::sanitize($path);
60 }
61 
69 function elgg_get_asset_path() {
70  $path = _elgg_services()->config->assetroot ? : elgg_get_cache_path() . 'views_simplecache/';
71  return Paths::sanitize($path);
72 }
73 
84 function elgg_get_root_path() {
85  return Paths::project();
86 }
87 
97 function elgg_sanitize_path(string $path, bool $append_slash = true): string {
98  return Paths::sanitize($path, $append_slash);
99 }
100 
108 function elgg_get_release(): string {
109  static $release;
110 
111  if (!isset($release)) {
112  $composerJson = file_get_contents(\Elgg\Project\Paths::elgg() . 'composer.json');
113  if ($composerJson === false) {
114  throw new ElggException("Unable to read composer.json file!");
115  }
116 
117  $composer = json_decode($composerJson);
118  if ($composer === null) {
119  throw new ElggException("JSON parse error while reading composer.json!");
120  }
121 
122  // Human-friendly version name
123  if (!isset($composer->version)) {
124  throw new ElggException("Version field must be set in composer.json!");
125  }
126  $release = $composer->version;
127  }
128 
129  return $release;
130 }
131 
141 function elgg_get_config($name, $default = null) {
142  if (!_elgg_services()->config->hasValue($name)) {
143  elgg_log("Config value for '$name' is not set'", 'INFO');
144  return $default;
145  }
146 
147  return _elgg_services()->config->$name;
148 }
149 
162  _elgg_services()->config->$name = $value;
163 }
164 
175  return _elgg_services()->config->save($name, $value);
176 }
177 
186  return _elgg_services()->config->remove($name);
187 }
188 
197 function elgg_get_icon_sizes($entity_type = null, $entity_subtype = null, $type = 'icon') {
198  return _elgg_services()->iconService->getSizes($entity_type, $entity_subtype, $type);
199 }
200 
209  $params = [
210  'entity' => $container,
211  ];
212  return (bool) elgg_trigger_plugin_hook('config', 'comments_latest_first', $params, (bool) _elgg_services()->config->comments_latest_first);
213 }
214 
223  $params = [
224  'entity' => $container,
225  ];
226  return (int) elgg_trigger_plugin_hook('config', 'comments_per_page', $params, _elgg_services()->config->comments_per_page);
227 }
$default
Definition: checkbox.php:31
elgg_get_release()
Get the current Elgg release.
elgg_get_asset_path()
Get the asset cache directory path for this installation, ending with slash.
$params
Saves global plugin settings.
Definition: save.php:13
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
elgg_get_icon_sizes($entity_type=null, $entity_subtype=null, $type= 'icon')
Returns a configuration array of icon sizes.
elgg_sanitize_path(string $path, bool $append_slash=true)
Sanitize file paths ensuring that they begin and end with slashes etc.
$type
Definition: delete.php:21
elgg_comments_per_page(ElggEntity $container=null)
How many comments appear per page.
$value
Definition: generic.php:51
elgg_save_config($name, $value)
Save a configuration setting.
string project
Definition: conf.py:48
$path
Definition: details.php:68
elgg_get_cache_path()
Get the cache directory path for this installation, ending with slash.
elgg_set_config($name, $value)
Set an Elgg configuration value.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:399
elgg_get_root_path()
Get the project path (where composer is installed), ending with slash.
$container
Definition: delete.php:23
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:380
elgg_get_site_url()
Get the URL for the current (or specified) site, ending with "/".
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
elgg_get_plugins_path()
Get the plugin path for this installation, ending with slash.
elgg_get_data_path()
Get the data directory path for this installation, ending with slash.
elgg_comments_are_latest_first(ElggEntity $container=null)
Are comments displayed with latest first?
elgg_remove_config($name)
Removes a config setting.
var elgg
Definition: elgglib.js:4
elgg_get_config($name, $default=null)
Get an Elgg configuration value.