1. sfActionStack.class.php
  2. /** * sfActionStack keeps a list of all requested actions and provides accessor * methods for retrieving individual entries. * * @package symfony * @subpackage action * @author Fabien Potencier * @author Sean Kerr * @version SVN: $Id: sfActionStack.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $ */
  3. class sfActionStack
  4. {
  5. protected
  6. $stack = array();
  7. /**
  8. * Adds an entry to the action stack.
  9. *
  10. * @param string $moduleName A module name
  11. * @param string $actionName An action name
  12. * @param sfAction $actionInstance An sfAction implementation instance
  13. *
  14. * @return sfActionStackEntry sfActionStackEntry instance
  15. */
  16. public function addEntry($moduleName, $actionName, $actionInstance)
  17. {
  18. // create our action stack entry and add it to our stack
  19. $actionEntry = new sfActionStackEntry($moduleName, $actionName, $actionInstance);
  20. $this->stack[] = $actionEntry;
  21. return $actionEntry;
  22. }
  23. /**
  24. * Retrieves the entry at a specific index.
  25. *
  26. * @param int $index An entry index
  27. *
  28. * @return sfActionStackEntry An action stack entry implementation.
  29. */
  30. public function getEntry($index)
  31. {
  32. $retval = null;
  33. if ($index > -1 && $index < count($this->stack))
  34. {
  35. $retval = $this->stack[$index];
  36. }
  37. return $retval;
  38. }
  39. /**
  40. * Removes the entry at a specific index.
  41. *
  42. * @return sfActionStackEntry An action stack entry implementation.
  43. */
  44. public function popEntry()
  45. {
  46. return array_pop($this->stack);
  47. }
  48. /**
  49. * Retrieves the first entry.
  50. *
  51. * @return mixed An action stack entry implementation or null if there is no sfAction instance in the stack
  52. */
  53. public function getFirstEntry()
  54. {
  55. $retval = null;
  56. if (isset($this->stack[0]))
  57. {
  58. $retval = $this->stack[0];
  59. }
  60. return $retval;
  61. }
  62. /**
  63. * Retrieves the last entry.
  64. *
  65. * @return mixed An action stack entry implementation or null if there is no sfAction instance in the stack
  66. */
  67. public function getLastEntry()
  68. {
  69. $count = count($this->stack);
  70. $retval = null;
  71. if (isset($this->stack[0]))
  72. {
  73. $retval = $this->stack[$count - 1];
  74. }
  75. return $retval;
  76. }
  77. /**
  78. * Retrieves the size of this stack.
  79. *
  80. * @return int The size of this stack.
  81. */
  82. public function getSize()
  83. {
  84. return count($this->stack);
  85. }
  86. }

Debug toolbar