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:      */
 67:     public function __construct($name, $method, array $params, array $post = array(), array $files = array(), array $flags = array())
 68:     {
 69:         $this->name = $name;
 70:         $this->method = $method;
 71:         $this->params = $params;
 72:         $this->post = $post;
 73:         $this->files = $files;
 74:         $this->flags = $flags;
 75:     }
 76: 
 77: 
 78: 
 79:     /**
 80:      * Sets the presenter name.
 81:      * @param  string
 82:      * @return Request  provides a fluent interface
 83:      */
 84:     public function setPresenterName($name)
 85:     {
 86:         $this->updating();
 87:         $this->name = $name;
 88:         return $this;
 89:     }
 90: 
 91: 
 92: 
 93:     /**
 94:      * Retrieve the presenter name.
 95:      * @return string
 96:      */
 97:     public function getPresenterName()
 98:     {
 99:         return $this->name;
100:     }
101: 
102: 
103: 
104:     /**
105:      * Sets variables provided to the presenter.
106:      * @param  array
107:      * @return Request  provides a fluent interface
108:      */
109:     public function setParameters(array $params)
110:     {
111:         $this->updating();
112:         $this->params = $params;
113:         return $this;
114:     }
115: 
116: 
117: 
118:     /**
119:      * Returns all variables provided to the presenter (usually via URL).
120:      * @return array
121:      */
122:     public function getParameters()
123:     {
124:         return $this->params;
125:     }
126: 
127: 
128: 
129:     /** @deprecated */
130:     function setParams(array $params)
131:     {
132:         trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
133:         return $this->setParameters($params);
134:     }
135: 
136: 
137: 
138:     /** @deprecated */
139:     function getParams()
140:     {
141:         trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
142:         return $this->getParameters();
143:     }
144: 
145: 
146: 
147:     /**
148:      * Sets variables provided to the presenter via POST.
149:      * @param  array
150:      * @return Request  provides a fluent interface
151:      */
152:     public function setPost(array $params)
153:     {
154:         $this->updating();
155:         $this->post = $params;
156:         return $this;
157:     }
158: 
159: 
160: 
161:     /**
162:      * Returns all variables provided to the presenter via POST.
163:      * @return array
164:      */
165:     public function getPost()
166:     {
167:         return $this->post;
168:     }
169: 
170: 
171: 
172:     /**
173:      * Sets all uploaded files.
174:      * @param  array
175:      * @return Request  provides a fluent interface
176:      */
177:     public function setFiles(array $files)
178:     {
179:         $this->updating();
180:         $this->files = $files;
181:         return $this;
182:     }
183: 
184: 
185: 
186:     /**
187:      * Returns all uploaded files.
188:      * @return array
189:      */
190:     public function getFiles()
191:     {
192:         return $this->files;
193:     }
194: 
195: 
196: 
197:     /**
198:      * Sets the method.
199:      * @param  string
200:      * @return Request  provides a fluent interface
201:      */
202:     public function setMethod($method)
203:     {
204:         $this->method = $method;
205:         return $this;
206:     }
207: 
208: 
209: 
210:     /**
211:      * Returns the method.
212:      * @return string
213:      */
214:     public function getMethod()
215:     {
216:         return $this->method;
217:     }
218: 
219: 
220: 
221:     /**
222:      * Checks if the method is the given one.
223:      * @param  string
224:      * @return bool
225:      */
226:     public function isMethod($method)
227:     {
228:         return strcasecmp($this->method, $method) === 0;
229:     }
230: 
231: 
232: 
233:     /**
234:      * Checks if the method is POST.
235:      * @return bool
236:      */
237:     public function isPost()
238:     {
239:         return strcasecmp($this->method, 'post') === 0;
240:     }
241: 
242: 
243: 
244:     /**
245:      * Sets the flag.
246:      * @param  string
247:      * @param  bool
248:      * @return Request  provides a fluent interface
249:      */
250:     public function setFlag($flag, $value = TRUE)
251:     {
252:         $this->updating();
253:         $this->flags[$flag] = (bool) $value;
254:         return $this;
255:     }
256: 
257: 
258: 
259:     /**
260:      * Checks the flag.
261:      * @param  string
262:      * @return bool
263:      */
264:     public function hasFlag($flag)
265:     {
266:         return !empty($this->flags[$flag]);
267:     }
268: 
269: }
270: 
Nette Framework 2.0.0 API API documentation generated by ApiGen 2.7.0