Elgg  Version 5.1
configuration.php
Go to the documentation of this file.
1 <?php
19 
26 function elgg_get_site_url(): string {
27  return _elgg_services()->config->wwwroot;
28 }
29 
36 function elgg_get_plugins_path(): string {
37  return _elgg_services()->plugins->getPath();
38 }
39 
46 function elgg_get_data_path(): string {
47  return _elgg_services()->config->dataroot;
48 }
49 
57 function elgg_get_cache_path(): string {
58  $path = _elgg_services()->config->cacheroot ?: elgg_get_data_path() . 'caches/';
59  return Paths::sanitize($path);
60 }
61 
69 function elgg_get_asset_path(): string {
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(): string {
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 
127  $release = $composer->version;
128  }
129 
130  return $release;
131 }
132 
142 function elgg_get_config(string $name, $default = null) {
143  if (!_elgg_services()->config->hasValue($name)) {
144  elgg_log("Config value for '$name' is not set'", 'INFO');
145  return $default;
146  }
147 
148  return _elgg_services()->config->$name;
149 }
150 
162 function elgg_set_config(string $name, $value): void {
163  _elgg_services()->config->$name = $value;
164 }
165 
175 function elgg_save_config(string $name, $value): bool {
176  return _elgg_services()->config->save($name, $value);
177 }
178 
186 function elgg_remove_config(string $name): bool {
187  return _elgg_services()->config->remove($name);
188 }
189 
198 function elgg_get_icon_sizes(string $entity_type = null, string $entity_subtype = null, $type = 'icon'): array {
199  return _elgg_services()->iconService->getSizes($entity_type, $entity_subtype, $type);
200 }
201 
210  $params = [
211  'entity' => $container,
212  ];
213  return (bool) elgg_trigger_event_results('config', 'comments_latest_first', $params, (bool) _elgg_services()->config->comments_latest_first);
214 }
215 
224  $params = [
225  'entity' => $container,
226  ];
227  return (int) elgg_trigger_event_results('config', 'comments_per_page', $params, _elgg_services()->config->comments_per_page);
228 }
$default
Definition: checkbox.php:30
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
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
elgg_get_icon_sizes(string $entity_type=null, string $entity_subtype=null, $type= 'icon')
Returns a configuration array of icon sizes.
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
elgg_sanitize_path(string $path, bool $append_slash=true)
Sanitize file paths ensuring that they begin and end with slashes etc.
elgg_comments_per_page(\ElggEntity $container=null)
How many comments appear per page.
$type
Definition: delete.php:22
elgg_trigger_event_results(string $event, string $type, array $params=[], $returnvalue=null)
Triggers an event where it is expected that the mixed return value could be manipulated by event call...
Definition: events.php:117
$value
Definition: generic.php:51
string project
Definition: conf.py:49
$path
Definition: details.php:70
elgg_set_config(string $name, $value)
Set an Elgg configuration value.
elgg_get_cache_path()
Get the cache directory path for this installation, ending with slash.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:86
elgg_save_config(string $name, $value)
Save a configuration setting.
elgg_get_root_path()
Get the project path (where composer is installed), ending with slash.
$container
Definition: delete.php:24
elgg_get_site_url()
Get the URL for the current (or specified) site, ending with "/".
elgg_remove_config(string $name)
Removes a config setting.
elgg_comments_are_latest_first(\ElggEntity $container=null)
Are comments displayed with latest first?
_elgg_services()
Get the global service provider.
Definition: elgglib.php:346
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.
var elgg
Definition: elgglib.js:4