Skip to content

Instantly share code, notes, and snippets.

@xtfer
Created February 3, 2016 05:16
Show Gist options
  • Save xtfer/322fd19a9f17e1c7abe4 to your computer and use it in GitHub Desktop.
Save xtfer/322fd19a9f17e1c7abe4 to your computer and use it in GitHub Desktop.
Globals usage information
<?php
/**
* Get a global value.
*
* A useful shorthand for accessing the Globals object.
*
* @param string $key
* Key to access
*
* @return mixed
* Result of the global
*/
function globals_get($key) {
return Globals::init()->getGlobalValue($key);
}
/**
* Get a global value filtered.
*
* @param string $key
* Global value key
* @param string $check_function
* Filter name. Defaults to 'check_plain'. If you provide another filter
* value, its up to you to ensure the output is secure.
*
* @return mixed
* Result of the query.
* @throws \Drupal\ghost\Exception\GhostException
*/
function globals_filter($key, $check_function = 'check_plain') {
return Globals::init()->getFilteredValue($key, $check_function);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment