Elgg  Version master
AddColorSchemeHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Page;
4 
11 
19  public function __invoke(\Elgg\Event $event): ?array {
20  if (!elgg_get_config('color_schemes_enabled')) {
21  return null;
22  }
23 
24  $vars = $event->getValue();
25 
26  if (elgg_in_context('admin')) {
27  // @todo make admin backend support color schemes
28  $vars['html_attrs']['data-color-scheme'] = 'default';
29 
30  return $vars;
31  }
32 
33  $color_scheme = elgg_get_logged_in_user_entity()?->elgg_color_scheme;
34  if (!isset($color_scheme) || $color_scheme === 'browser') {
35  return null;
36  }
37 
38  $vars['html_attrs']['data-color-scheme'] = $color_scheme;
39 
40  return $vars;
41  }
42 }
$vars
Definition: theme.php:3
Models an event passed to event handlers.
Definition: Event.php:11
Add color scheme information to page html.
__invoke(\Elgg\Event $event)
Add color scheme information to page html.
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
elgg_in_context(string $context)
Check if this context exists anywhere in the stack.
Definition: context.php:78
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
Definition: robots.php:10
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:24