Elgg  Version 1.10
Context.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
3 
27 final class Context {
28 
29  private $stack = array();
30 
36  public function peek() {
37  $topPos = count($this->stack) - 1;
38 
39  if ($topPos >= 0) {
40  return $this->stack[$topPos];
41  } else {
42  return NULL;
43  }
44 
45  }
46 
53  public function push($context) {
54  array_push($this->stack, $context);
55  }
56 
62  public function pop() {
63  return array_pop($this->stack);
64  }
65 
72  public function set($context) {
73  $context = trim($context);
74 
75  if (empty($context)) {
76  return false;
77  }
78 
79  $context = strtolower($context);
80 
81  $this->pop();
82  $this->push($context);
83 
84  return true;
85  }
86 
98  public function contains($context) {
99  return in_array($context, $this->stack);
100  }
101 }
peek()
Get the most recently pushed context value.
Definition: Context.php:36
$context
Definition: add.php:11
pop()
Removes and returns the top context string from the stack.
Definition: Context.php:62
contains($context)
Check if this context exists anywhere in the stack.
Definition: Context.php:98
push($context)
Push a context onto the top of the stack.
Definition: Context.php:53
Save menu items.