Namespaces

  • Nette
    • Application
    • Caching
    • Collections
    • Config
    • Forms
    • IO
    • Loaders
    • Mail
    • Reflection
    • Security
    • Templates
    • Web
  • None
  • PHP

Classes

  • AppForm
  • Application
  • CliRouter
  • Control
  • DownloadResponse
  • ForwardingResponse
  • JsonResponse
  • Link
  • MultiRouter
  • Presenter
  • PresenterComponent
  • PresenterLoader
  • PresenterRequest
  • RedirectingResponse
  • RenderResponse
  • Route
  • SimpleRouter

Interfaces

  • IPartiallyRenderable
  • IPresenter
  • IPresenterLoader
  • IPresenterResponse
  • IRenderable
  • IRouter
  • ISignalReceiver
  • IStatePersistent

Exceptions

  • AbortException
  • ApplicationException
  • BadRequestException
  • BadSignalException
  • ForbiddenRequestException
  • InvalidLinkException
  • InvalidPresenterException
  • Overview
  • Namespace
  • Class
  • Tree
  • Other releases
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (https://nette.org)
  5:  *
  6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
  7:  *
  8:  * For the full copyright and license information, please view
  9:  * the file license.txt that was distributed with this source code.
 10:  */
 11: 
 12: namespace Nette\Application;
 13: 
 14: use Nette;
 15: 
 16: 
 17: 
 18: /**
 19:  * Presenter request. Immutable object.
 20:  *
 21:  * @author     David Grudl
 22:  *
 23:  * @property   string $presenterName
 24:  * @property   array $params
 25:  * @property   array $post
 26:  * @property   array $files
 27:  */
 28: final class PresenterRequest extends Nette\FreezableObject
 29: {
 30:     /** method */
 31:     const FORWARD = 'FORWARD';
 32: 
 33:     /** flag */
 34:     const SECURED = 'secured';
 35: 
 36:     /** flag */
 37:     const RESTORED = 'restored';
 38: 
 39:     /** @var string */
 40:     private $method;
 41: 
 42:     /** @var array */
 43:     private $flags = array();
 44: 
 45:     /** @var string */
 46:     private $name;
 47: 
 48:     /** @var array */
 49:     private $params;
 50: 
 51:     /** @var array */
 52:     private $post;
 53: 
 54:     /** @var array */
 55:     private $files;
 56: 
 57: 
 58: 
 59:     /**
 60:      * @param  string  fully qualified presenter name (module:module:presenter)
 61:      * @param  string  method
 62:      * @param  array   variables provided to the presenter usually via URL
 63:      * @param  array   variables provided to the presenter via POST
 64:      * @param  array   all uploaded files
 65:      */
 66:     public function __construct($name, $method, array $params, array $post = array(), array $files = array(), array $flags = array())
 67:     {
 68:         $this->name = $name;
 69:         $this->method = $method;
 70:         $this->params = $params;
 71:         $this->post = $post;
 72:         $this->files = $files;
 73:         $this->flags = $flags;
 74:     }
 75: 
 76: 
 77: 
 78:     /**
 79:      * Sets the presenter name.
 80:      * @param  string
 81:      * @return PresenterRequest  provides a fluent interface
 82:      */
 83:     public function setPresenterName($name)
 84:     {
 85:         $this->updating();
 86:         $this->name = $name;
 87:         return $this;
 88:     }
 89: 
 90: 
 91: 
 92:     /**
 93:      * Retrieve the presenter name.
 94:      * @return string
 95:      */
 96:     public function getPresenterName()
 97:     {
 98:         return $this->name;
 99:     }
100: 
101: 
102: 
103:     /**
104:      * Sets variables provided to the presenter.
105:      * @param  array
106:      * @return PresenterRequest  provides a fluent interface
107:      */
108:     public function setParams(array $params)
109:     {
110:         $this->updating();
111:         $this->params = $params;
112:         return $this;
113:     }
114: 
115: 
116: 
117:     /**
118:      * Returns all variables provided to the presenter (usually via URL).
119:      * @return array
120:      */
121:     public function getParams()
122:     {
123:         return $this->params;
124:     }
125: 
126: 
127: 
128:     /**
129:      * Sets variables provided to the presenter via POST.
130:      * @param  array
131:      * @return PresenterRequest  provides a fluent interface
132:      */
133:     public function setPost(array $params)
134:     {
135:         $this->updating();
136:         $this->post = $params;
137:         return $this;
138:     }
139: 
140: 
141: 
142:     /**
143:      * Returns all variables provided to the presenter via POST.
144:      * @return array
145:      */
146:     public function getPost()
147:     {
148:         return $this->post;
149:     }
150: 
151: 
152: 
153:     /**
154:      * Sets all uploaded files.
155:      * @param  array
156:      * @return PresenterRequest  provides a fluent interface
157:      */
158:     public function setFiles(array $files)
159:     {
160:         $this->updating();
161:         $this->files = $files;
162:         return $this;
163:     }
164: 
165: 
166: 
167:     /**
168:      * Returns all uploaded files.
169:      * @return array
170:      */
171:     public function getFiles()
172:     {
173:         return $this->files;
174:     }
175: 
176: 
177: 
178:     /**
179:      * Sets the method.
180:      * @param  string
181:      * @return PresenterRequest  provides a fluent interface
182:      */
183:     public function setMethod($method)
184:     {
185:         $this->method = $method;
186:         return $this;
187:     }
188: 
189: 
190: 
191:     /**
192:      * Returns the method.
193:      * @return string
194:      */
195:     public function getMethod()
196:     {
197:         return $this->method;
198:     }
199: 
200: 
201: 
202:     /**
203:      * Checks if the method is the given one.
204:      * @param  string
205:      * @return bool
206:      */
207:     public function isMethod($method)
208:     {
209:         return strcasecmp($this->method, $method) === 0;
210:     }
211: 
212: 
213: 
214:     /**
215:      * Checks if the method is POST.
216:      * @return bool
217:      */
218:     public function isPost()
219:     {
220:         return strcasecmp($this->method, 'post') === 0;
221:     }
222: 
223: 
224: 
225:     /**
226:      * Sets the flag.
227:      * @param  string
228:      * @param  bool
229:      * @return PresenterRequest  provides a fluent interface
230:      */
231:     public function setFlag($flag, $value = TRUE)
232:     {
233:         $this->updating();
234:         $this->flags[$flag] = (bool) $value;
235:         return $this;
236:     }
237: 
238: 
239: 
240:     /**
241:      * Checks the flag.
242:      * @param  string
243:      * @return bool
244:      */
245:     public function hasFlag($flag)
246:     {
247:         return !empty($this->flags[$flag]);
248:     }
249: 
250: }
251: 
Nette Framework 0.9.7 API documentation generated by ApiGen 2.3.0