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
  • Deprecated
  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:      * @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:      * @return Request  provides a fluent interface
150:      */
151:     public function setPost(array $params)
152:     {
153:         $this->updating();
154:         $this->post = $params;
155:         return $this;
156:     }
157: 
158: 
159: 
160:     /**
161:      * Returns all variables provided to the presenter via POST.
162:      * @return array
163:      */
164:     public function getPost()
165:     {
166:         return $this->post;
167:     }
168: 
169: 
170: 
171:     /**
172:      * Sets all uploaded files.
173:      * @return Request  provides a fluent interface
174:      */
175:     public function setFiles(array $files)
176:     {
177:         $this->updating();
178:         $this->files = $files;
179:         return $this;
180:     }
181: 
182: 
183: 
184:     /**
185:      * Returns all uploaded files.
186:      * @return array
187:      */
188:     public function getFiles()
189:     {
190:         return $this->files;
191:     }
192: 
193: 
194: 
195:     /**
196:      * Sets the method.
197:      * @param  string
198:      * @return Request  provides a fluent interface
199:      */
200:     public function setMethod($method)
201:     {
202:         $this->method = $method;
203:         return $this;
204:     }
205: 
206: 
207: 
208:     /**
209:      * Returns the method.
210:      * @return string
211:      */
212:     public function getMethod()
213:     {
214:         return $this->method;
215:     }
216: 
217: 
218: 
219:     /**
220:      * Checks if the method is the given one.
221:      * @param  string
222:      * @return bool
223:      */
224:     public function isMethod($method)
225:     {
226:         return strcasecmp($this->method, $method) === 0;
227:     }
228: 
229: 
230: 
231:     /**
232:      * Checks if the method is POST.
233:      * @return bool
234:      */
235:     public function isPost()
236:     {
237:         return strcasecmp($this->method, 'post') === 0;
238:     }
239: 
240: 
241: 
242:     /**
243:      * Sets the flag.
244:      * @param  string
245:      * @param  bool
246:      * @return Request  provides a fluent interface
247:      */
248:     public function setFlag($flag, $value = TRUE)
249:     {
250:         $this->updating();
251:         $this->flags[$flag] = (bool) $value;
252:         return $this;
253:     }
254: 
255: 
256: 
257:     /**
258:      * Checks the flag.
259:      * @param  string
260:      * @return bool
261:      */
262:     public function hasFlag($flag)
263:     {
264:         return !empty($this->flags[$flag]);
265:     }
266: 
267: }
268: 
Nette Framework 2.0.10 API API documentation generated by ApiGen 2.8.0