| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
class sfActionStack |
|---|
| 23 |
{ |
|---|
| 24 |
protected |
|---|
| 25 |
$stack = array(); |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
* Adds an entry to the action stack. |
|---|
| 29 |
* |
|---|
| 30 |
* @param string A module name |
|---|
| 31 |
* @param string An action name |
|---|
| 32 |
* @param sfAction An sfAction implementation instance |
|---|
| 33 |
* |
|---|
| 34 |
* @return sfActionStackEntry sfActionStackEntry instance |
|---|
| 35 |
*/ |
|---|
| 36 |
public function addEntry($moduleName, $actionName, $actionInstance) |
|---|
| 37 |
{ |
|---|
| 38 |
|
|---|
| 39 |
$actionEntry = new sfActionStackEntry($moduleName, $actionName, $actionInstance); |
|---|
| 40 |
|
|---|
| 41 |
$this->stack[] = $actionEntry; |
|---|
| 42 |
|
|---|
| 43 |
return $actionEntry; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
* Retrieves the entry at a specific index. |
|---|
| 48 |
* |
|---|
| 49 |
* @param int An entry index |
|---|
| 50 |
* |
|---|
| 51 |
* @return sfActionStackEntry An action stack entry implementation. |
|---|
| 52 |
*/ |
|---|
| 53 |
public function getEntry($index) |
|---|
| 54 |
{ |
|---|
| 55 |
$retval = null; |
|---|
| 56 |
|
|---|
| 57 |
if ($index > -1 && $index < count($this->stack)) |
|---|
| 58 |
{ |
|---|
| 59 |
$retval = $this->stack[$index]; |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
return $retval; |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
* Removes the entry at a specific index. |
|---|
| 67 |
* |
|---|
| 68 |
* @param int An entry index |
|---|
| 69 |
* |
|---|
| 70 |
* @return sfActionStackEntry An action stack entry implementation. |
|---|
| 71 |
*/ |
|---|
| 72 |
public function popEntry() |
|---|
| 73 |
{ |
|---|
| 74 |
return array_pop($this->stack); |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
* Retrieves the first entry. |
|---|
| 79 |
* |
|---|
| 80 |
* @return mixed An action stack entry implementation or null if there is no sfAction instance in the stack |
|---|
| 81 |
*/ |
|---|
| 82 |
public function getFirstEntry() |
|---|
| 83 |
{ |
|---|
| 84 |
$retval = null; |
|---|
| 85 |
|
|---|
| 86 |
if (isset($this->stack[0])) |
|---|
| 87 |
{ |
|---|
| 88 |
$retval = $this->stack[0]; |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
return $retval; |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
* Retrieves the last entry. |
|---|
| 96 |
* |
|---|
| 97 |
* @return mixed An action stack entry implementation or null if there is no sfAction instance in the stack |
|---|
| 98 |
*/ |
|---|
| 99 |
public function getLastEntry() |
|---|
| 100 |
{ |
|---|
| 101 |
$count = count($this->stack); |
|---|
| 102 |
$retval = null; |
|---|
| 103 |
|
|---|
| 104 |
if (isset($this->stack[0])) |
|---|
| 105 |
{ |
|---|
| 106 |
$retval = $this->stack[$count - 1]; |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
return $retval; |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
* Retrieves the size of this stack. |
|---|
| 114 |
* |
|---|
| 115 |
* @return int The size of this stack. |
|---|
| 116 |
*/ |
|---|
| 117 |
public function getSize() |
|---|
| 118 |
{ |
|---|
| 119 |
return count($this->stack); |
|---|
| 120 |
} |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|