Elgg  Version 4.x
configuration.php
Go to the documentation of this file.
1 <?php
18 
25 function elgg_get_site_url() {
26  return _elgg_services()->config->wwwroot;
27 }
28 
36  return _elgg_services()->plugins->getPath();
37 }
38 
45 function elgg_get_data_path() {
46  return _elgg_services()->config->dataroot;
47 }
48 
56 function elgg_get_cache_path() {
57  $path = _elgg_services()->config->cacheroot ? : elgg_get_data_path() . 'caches/';
58  return Paths::sanitize($path);
59 }
60 
68 function elgg_get_asset_path() {
69  $path = _elgg_services()->config->assetroot ? : elgg_get_cache_path() . 'views_simplecache/';
70  return Paths::sanitize($path);
71 }
72 
83 function elgg_get_root_path() {
84  return Paths::project();
85 }
86 
93  return Paths::elgg() . 'engine';
94 }
95 
103 function elgg_get_release(): string {
104  static $release;
105 
106  if (!isset($release)) {
107  $composerJson = file_get_contents(\Elgg\Project\Paths::elgg() . 'composer.json');
108  if ($composerJson === false) {
109  throw new Exception("Unable to read composer.json file!");
110  }
111 
112  $composer = json_decode($composerJson);
113  if ($composer === null) {
114  throw new Exception("JSON parse error while reading composer.json!");
115  }
116 
117  // Human-friendly version name
118  if (!isset($composer->version)) {
119  throw new Exception("Version field must be set in composer.json!");
120  }
121  $release = $composer->version;
122  }
123 
124  return $release;
125 }
126 
136 function elgg_get_config($name, $default = null) {
137  if (!_elgg_services()->config->hasValue($name)) {
138  elgg_log("Config value for '$name' is not set'", 'INFO');
139  return $default;
140  }
141 
142  return _elgg_services()->config->$name;
143 }
144 
157  _elgg_services()->config->$name = $value;
158 }
159 
170  return _elgg_services()->config->save($name, $value);
171 }
172 
181  return _elgg_services()->config->remove($name);
182 }
183 
192 function elgg_get_icon_sizes($entity_type = null, $entity_subtype = null, $type = 'icon') {
193  return _elgg_services()->iconService->getSizes($entity_type, $entity_subtype, $type);
194 }
195 
204  $params = [
205  'entity' => $container,
206  ];
207  return (bool) elgg_trigger_plugin_hook('config', 'comments_latest_first', $params, (bool) _elgg_services()->config->comments_latest_first);
208 }
209 
218  $params = [
219  'entity' => $container,
220  ];
221  return (int) elgg_trigger_plugin_hook('config', 'comments_per_page', $params, _elgg_services()->config->comments_per_page);
222 }
$default
Definition: checkbox.php:31
elgg_get_release()
Get the current Elgg release.
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
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
elgg_get_icon_sizes($entity_type=null, $entity_subtype=null, $type= 'icon')
Returns a configuration array of icon sizes.
$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.
$container
Definition: delete.php:23
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.
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_get_engine_path()
/path/to/elgg/engine with no trailing slash.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:777
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.