Elgg  Version 6.2
configuration.php
Go to the documentation of this file.
1 <?php
17 use Elgg\Exceptions\Exception as ElggException;
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()->config->plugins_path;
38 }
39 
46 function elgg_get_data_path(): string {
47  return _elgg_services()->config->dataroot;
48 }
49 
55 function elgg_get_cache_path(): string {
56  return _elgg_services()->config->cacheroot;
57 }
58 
64 function elgg_get_asset_path(): string {
65  return _elgg_services()->config->assetroot;
66 }
67 
78 function elgg_get_root_path(): string {
79  return Paths::project();
80 }
81 
91 function elgg_sanitize_path(string $path, bool $append_slash = true): string {
92  return Paths::sanitize($path, $append_slash);
93 }
94 
102 function elgg_get_release(): string {
103  static $release;
104 
105  if (!isset($release)) {
106  $composerJson = file_get_contents(\Elgg\Project\Paths::elgg() . 'composer.json');
107  if ($composerJson === false) {
108  throw new ElggException('Unable to read composer.json file!');
109  }
110 
111  $composer = json_decode($composerJson);
112  if ($composer === null) {
113  throw new ElggException('JSON parse error while reading composer.json!');
114  }
115 
116  // Human-friendly version name
117  if (!isset($composer->version)) {
118  throw new ElggException('Version field must be set in composer.json!');
119  }
120 
121  $release = $composer->version;
122  }
123 
124  return $release;
125 }
126 
136 function elgg_get_config(string $name, $default = null) {
137  if (!_elgg_services()->config->hasValue($name)) {
138  _elgg_services()->logger->info("Config value for '{$name}' is not set");
139  return $default;
140  }
141 
142  return _elgg_services()->config->$name;
143 }
144 
156 function elgg_set_config(string $name, $value): void {
157  _elgg_services()->config->$name = $value;
158 }
159 
169 function elgg_save_config(string $name, $value): bool {
170  return _elgg_services()->config->save($name, $value);
171 }
172 
180 function elgg_remove_config(string $name): bool {
181  return _elgg_services()->config->remove($name);
182 }
183 
192 function elgg_get_icon_sizes(?string $entity_type = null, ?string $entity_subtype = null, $type = 'icon'): array {
193  return _elgg_services()->iconService->getSizes($entity_type, $entity_subtype, $type);
194 }
195 
205  $params = [
206  'entity' => $container,
207  ];
208  return (bool) elgg_trigger_event_results('config', 'comments_latest_first', $params, (bool) _elgg_services()->config->comments_latest_first);
209 }
210 
220  $params = [
221  'entity' => $container,
222  ];
223  return (int) elgg_trigger_event_results('config', 'comments_per_page', $params, _elgg_services()->config->comments_per_page);
224 }
if(! $user||! $user->canDelete()) $name
Definition: delete.php:22
$type
Definition: delete.php:21
$container
Definition: delete.php:23
$params
Saves global plugin settings.
Definition: save.php:13
return[ 'admin/delete_admin_notices'=>['access'=> 'admin'], 'admin/menu/save'=>['access'=> 'admin'], 'admin/plugins/activate'=>['access'=> 'admin'], 'admin/plugins/activate_all'=>['access'=> 'admin'], 'admin/plugins/deactivate'=>['access'=> 'admin'], 'admin/plugins/deactivate_all'=>['access'=> 'admin'], 'admin/plugins/set_priority'=>['access'=> 'admin'], 'admin/security/security_txt'=>['access'=> 'admin'], 'admin/security/settings'=>['access'=> 'admin'], 'admin/security/regenerate_site_secret'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['access'=> 'admin'], 'admin/site/flush_cache'=>['access'=> 'admin'], 'admin/site/icons'=>['access'=> 'admin'], 'admin/site/set_maintenance_mode'=>['access'=> 'admin'], 'admin/site/set_robots'=>['access'=> 'admin'], 'admin/site/theme'=>['access'=> 'admin'], 'admin/site/unlock_upgrade'=>['access'=> 'admin'], 'admin/site/settings'=>['access'=> 'admin'], 'admin/upgrade'=>['access'=> 'admin'], 'admin/upgrade/reset'=>['access'=> 'admin'], 'admin/user/ban'=>['access'=> 'admin'], 'admin/user/bulk/ban'=>['access'=> 'admin'], 'admin/user/bulk/delete'=>['access'=> 'admin'], 'admin/user/bulk/unban'=>['access'=> 'admin'], 'admin/user/bulk/validate'=>['access'=> 'admin'], 'admin/user/change_email'=>['access'=> 'admin'], 'admin/user/delete'=>['access'=> 'admin'], 'admin/user/login_as'=>['access'=> 'admin'], 'admin/user/logout_as'=>[], 'admin/user/makeadmin'=>['access'=> 'admin'], 'admin/user/resetpassword'=>['access'=> 'admin'], 'admin/user/removeadmin'=>['access'=> 'admin'], 'admin/user/unban'=>['access'=> 'admin'], 'admin/user/validate'=>['access'=> 'admin'], 'annotation/delete'=>[], 'avatar/upload'=>[], 'comment/save'=>[], 'diagnostics/download'=>['access'=> 'admin'], 'entity/chooserestoredestination'=>[], 'entity/delete'=>[], 'entity/mute'=>[], 'entity/restore'=>[], 'entity/subscribe'=>[], 'entity/trash'=>[], 'entity/unmute'=>[], 'entity/unsubscribe'=>[], 'login'=>['access'=> 'logged_out'], 'logout'=>[], 'notifications/mute'=>['access'=> 'public'], 'plugins/settings/remove'=>['access'=> 'admin'], 'plugins/settings/save'=>['access'=> 'admin'], 'plugins/usersettings/save'=>[], 'register'=>['access'=> 'logged_out', 'middleware'=>[\Elgg\Router\Middleware\RegistrationAllowedGatekeeper::class,],], 'river/delete'=>[], 'settings/notifications'=>[], 'settings/notifications/subscriptions'=>[], 'user/changepassword'=>['access'=> 'public'], 'user/requestnewpassword'=>['access'=> 'public'], 'useradd'=>['access'=> 'admin'], 'usersettings/save'=>[], 'widgets/add'=>[], 'widgets/delete'=>[], 'widgets/move'=>[], 'widgets/save'=>[],]
Definition: actions.php:73
Base exception of exceptions in the Elgg system.
Definition: Exception.php:11
Find Elgg and project paths.
Definition: Paths.php:8
elgg_sanitize_path(string $path, bool $append_slash=true)
Sanitize file paths ensuring that they begin and end with slashes etc.
elgg_get_plugins_path()
Get the plugin path for this installation, ending with slash.
elgg_comments_are_latest_first(?\ElggEntity $container=null)
Are comments displayed with latest first?
elgg_save_config(string $name, $value)
Save a configuration setting.
elgg_get_asset_path()
Get the asset cache directory path for this installation, ending with slash.
elgg_set_config(string $name, $value)
Set an Elgg configuration value.
elgg_get_root_path()
Get the project path (where composer is installed), ending with slash.
elgg_get_site_url()
Get the URL for the current (or specified) site, ending with "/".
elgg_get_cache_path()
Get the cache directory path for this installation, ending with slash.
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
elgg_comments_per_page(?\ElggEntity $container=null)
How many comments appear per page.
elgg_get_data_path()
Get the data directory path for this installation, ending with slash.
elgg_remove_config(string $name)
Removes a config setting.
elgg_get_icon_sizes(?string $entity_type=null, ?string $entity_subtype=null, $type='icon')
Returns a configuration array of icon sizes.
elgg_get_release()
Get the current Elgg release.
elgg()
Bootstrapping and helper procedural code available for use in Elgg core and plugins.
Definition: elgglib.php:12
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
$value
Definition: generic.php:51
$default
Definition: checkbox.php:30
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
string project
Definition: conf.py:52
$path
Definition: details.php:70
$CONFIG wwwroot
The installation root URL of the site.
if(!isset($CONFIG)) $CONFIG dataroot
The full file path for Elgg data storage.