Development

/branches/1.0/lib/action/sfActionStack.class.php

You must first sign up to be able to contribute.

root/branches/1.0/lib/action/sfActionStack.class.php

Revision 7791, 2.6 kB (checked in by fabien, 6 years ago)

updated Sean Kerr email address

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev Date
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  * (c) 2004-2006 Sean Kerr <sean@code-box.org>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 /**
13  * sfActionStack keeps a list of all requested actions and provides accessor
14  * methods for retrieving individual entries.
15  *
16  * @package    symfony
17  * @subpackage action
18  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
19  * @author     Sean Kerr <sean@code-box.org>
20  * @version    SVN: $Id$
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     // create our action stack entry and add it to our stack
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
Note: See TracBrowser for help on using the browser.