Development

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

You must first sign up to be able to contribute.

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

Revision 23810, 2.6 kB (checked in by Kris.Wallsmith, 4 years ago)

[1.3] set svn:eol-style property to native and svn:keywords property to Id on all .php files

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
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   $moduleName     A module name
31    * @param string   $actionName     An action name
32    * @param sfAction $actionInstance 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 $index 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    * @return sfActionStackEntry An action stack entry implementation.
69    */
70   public function popEntry()
71   {
72     return array_pop($this->stack);
73   }
74
75   /**
76    * Retrieves the first entry.
77    *
78    * @return mixed An action stack entry implementation or null if there is no sfAction instance in the stack
79    */
80   public function getFirstEntry()
81   {
82     $retval = null;
83
84     if (isset($this->stack[0]))
85     {
86       $retval = $this->stack[0];
87     }
88
89     return $retval;
90   }
91
92   /**
93    * Retrieves the last entry.
94    *
95    * @return mixed An action stack entry implementation or null if there is no sfAction instance in the stack
96    */
97   public function getLastEntry()
98   {
99     $count  = count($this->stack);
100     $retval = null;
101
102     if (isset($this->stack[0]))
103     {
104       $retval = $this->stack[$count - 1];
105     }
106
107     return $retval;
108   }
109
110   /**
111    * Retrieves the size of this stack.
112    *
113    * @return int The size of this stack.
114    */
115   public function getSize()
116   {
117     return count($this->stack);
118   }
119 }
120
Note: See TracBrowser for help on using the browser.