Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • Application
  • PresenterFactory
  • Request

Interfaces

  • IPresenter
  • IPresenterFactory
  • IResponse
  • IRouter

Exceptions

  • AbortException
  • ApplicationException
  • BadRequestException
  • ForbiddenRequestException
  • InvalidPresenterException
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (http://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 $parameters
 25:  * @property   array $post
 26:  * @property   array $files
 27:  * @property   string $method
 28:  */
 29: final class Request extends Nette\FreezableObject
 30: {
 31:     /** method */
 32:     const FORWARD = 'FORWARD';
 33: 
 34:     /** flag */
 35:     const SECURED = 'secured';
 36: 
 37:     /** flag */
 38:     const RESTORED = 'restored';
 39: 
 40:     /** @var string */
 41:     private $method;
 42: 
 43:     /** @var array */
 44:     private $flags = array();
 45: 
 46:     /** @var string */
 47:     private $name;
 48: 
 49:     /** @var array */
 50:     private $params;
 51: 
 52:     /** @var array */
 53:     private $post;
 54: 
 55:     /** @var array */
 56:     private $files;
 57: 
 58: 
 59: 
 60:     /**
 61:      * @param  string  fully qualified presenter name (module:module:presenter)
 62:      * @param  string  method
 63:      * @param  array   variables provided to the presenter usually via URL
 64:      * @param  array   variables provided to the presenter via POST
 65:      * @param  array   all uploaded files
 66:      * @param  array   flags
 67:      */
 68:     public function __construct($name, $method, array $params, array $post = array(), array $files = array(), array $flags = array())
 69:     {
 70:         $this->name = $name;
 71:         $this->method = $method;
 72:         $this->params = $params;
 73:         $this->post = $post;
 74:         $this->files = $files;
 75:         $this->flags = $flags;
 76:     }
 77: 
 78: 
 79: 
 80:     /**
 81:      * Sets the presenter name.
 82:      * @param  string
 83:      * @return Request  provides a fluent interface
 84:      */
 85:     public function setPresenterName($name)
 86:     {
 87:         $this->updating();
 88:         $this->name = $name;
 89:         return $this;
 90:     }
 91: 
 92: 
 93: 
 94:     /**
 95:      * Retrieve the presenter name.
 96:      * @return string
 97:      */
 98:     public function getPresenterName()
 99:     {
100:         return $this->name;
101:     }
102: 
103: 
104: 
105:     /**
106:      * Sets variables provided to the presenter.
107:      * @param  array
108:      * @return Request  provides a fluent interface
109:      */
110:     public function setParameters(array $params)
111:     {
112:         $this->updating();
113:         $this->params = $params;
114:         return $this;
115:     }
116: 
117: 
118: 
119:     /**
120:      * Returns all variables provided to the presenter (usually via URL).
121:      * @return array
122:      */
123:     public function getParameters()
124:     {
125:         return $this->params;
126:     }
127: 
128: 
129: 
130:     /** @deprecated */
131:     function setParams(array $params)
132:     {
133:         trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
134:         return $this->setParameters($params);
135:     }
136: 
137: 
138: 
139:     /** @deprecated */
140:     function getParams()
141:     {
142:         trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
143:         return $this->getParameters();
144:     }
145: 
146: 
147: 
148:     /**
149:      * Sets variables provided to the presenter via POST.
150:      * @param  array
151:      * @return Request  provides a fluent interface
152:      */
153:     public function setPost(array $params)
154:     {
155:         $this->updating();
156:         $this->post = $params;
157:         return $this;
158:     }
159: 
160: 
161: 
162:     /**
163:      * Returns all variables provided to the presenter via POST.
164:      * @return array
165:      */
166:     public function getPost()
167:     {
168:         return $this->post;
169:     }
170: 
171: 
172: 
173:     /**
174:      * Sets all uploaded files.
175:      * @param  array
176:      * @return Request  provides a fluent interface
177:      */
178:     public function setFiles(array $files)
179:     {
180:         $this->updating();
181:         $this->files = $files;
182:         return $this;
183:     }
184: 
185: 
186: 
187:     /**
188:      * Returns all uploaded files.
189:      * @return array
190:      */
191:     public function getFiles()
192:     {
193:         return $this->files;
194:     }
195: 
196: 
197: 
198:     /**
199:      * Sets the method.
200:      * @param  string
201:      * @return Request  provides a fluent interface
202:      */
203:     public function setMethod($method)
204:     {
205:         $this->method = $method;
206:         return $this;
207:     }
208: 
209: 
210: 
211:     /**
212:      * Returns the method.
213:      * @return string
214:      */
215:     public function getMethod()
216:     {
217:         return $this->method;
218:     }
219: 
220: 
221: 
222:     /**
223:      * Checks if the method is the given one.
224:      * @param  string
225:      * @return bool
226:      */
227:     public function isMethod($method)
228:     {
229:         return strcasecmp($this->method, $method) === 0;
230:     }
231: 
232: 
233: 
234:     /**
235:      * Checks if the method is POST.
236:      * @return bool
237:      */
238:     public function isPost()
239:     {
240:         return strcasecmp($this->method, 'post') === 0;
241:     }
242: 
243: 
244: 
245:     /**
246:      * Sets the flag.
247:      * @param  string
248:      * @param  bool
249:      * @return Request  provides a fluent interface
250:      */
251:     public function setFlag($flag, $value = TRUE)
252:     {
253:         $this->updating();
254:         $this->flags[$flag] = (bool) $value;
255:         return $this;
256:     }
257: 
258: 
259: 
260:     /**
261:      * Checks the flag.
262:      * @param  string
263:      * @return bool
264:      */
265:     public function hasFlag($flag)
266:     {
267:         return !empty($this->flags[$flag]);
268:     }
269: 
270: }
271: 
Nette Framework 2.0.4 API API documentation generated by ApiGen 2.7.0