Elgg
Version 2.3
|
Manages a global stack of strings for sharing information about the current execution context. More...
Public Member Functions | |
peek () | |
Get the most recently pushed context value. More... | |
push ($context) | |
Push a context onto the top of the stack. More... | |
pop () | |
Removes and returns the top context string from the stack. More... | |
set ($context) | |
Sets the page context. More... | |
contains ($context) | |
Check if this context exists anywhere in the stack. More... | |
toArray () | |
Get the entire context stack as an array (e.g. More... | |
fromArray (array $stack) | |
Overwrite the entire context stack from an array of strings. More... | |
Manages a global stack of strings for sharing information about the current execution context.
Views can modify their output based on the local context. You may want to display a list of blogs on a blog page or in a small widget. The rendered output could be different for those two contexts ('blog' vs 'widget').
Pages that pass through the page handling system set the context to the first string after the root url. Example: http://example.org/elgg/bookmarks/ results in the initial context being set to 'bookmarks'.
The context is a stack so that for a widget on a profile, the context stack may contain first 'profile' and then 'widget'.
private
Definition at line 24 of file Context.php.
Elgg\Context::contains | ( | $context | ) |
Check if this context exists anywhere in the stack.
This is useful for situations with more than one element in the stack. For example, a widget has a context of 'widget'. If a widget view needs to render itself differently based on being on the dashboard or profile pages, it can check the stack.
string | $context | The context string to check for |
Definition at line 89 of file Context.php.
Elgg\Context::fromArray | ( | array | $stack | ) |
Overwrite the entire context stack from an array of strings.
string[] | $stack All contexts to be placed on the stack |
Definition at line 108 of file Context.php.
Elgg\Context::peek | ( | ) |
Get the most recently pushed context value.
Definition at line 33 of file Context.php.
Elgg\Context::pop | ( | ) |
Removes and returns the top context string from the stack.
Definition at line 53 of file Context.php.
Elgg\Context::push | ( | $context | ) |
Push a context onto the top of the stack.
string | $context | The context string to add to the context stack |
Definition at line 44 of file Context.php.
Elgg\Context::set | ( | $context | ) |
Sets the page context.
string | $context | The context of the page |
Definition at line 63 of file Context.php.
Elgg\Context::toArray | ( | ) |
Get the entire context stack as an array (e.g.
for backing it up)
Definition at line 98 of file Context.php.