Packages

  • 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
  • PresenterRequest

Interfaces

  • IPresenter
  • IPresenterFactory
  • IPresenterResponse
  • IRouter

Exceptions

  • AbortException
  • ApplicationException
  • BadRequestException
  • ForbiddenRequestException
  • InvalidPresenterException
  • Overview
  • Package
  • 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:  * @package Nette\Application
 11:  */
 12: 
 13: 
 14: 
 15: /**
 16:  * Presenter request. Immutable object.
 17:  *
 18:  * @author     David Grudl
 19:  *
 20:  * @property   string $presenterName
 21:  * @property   array $parameters
 22:  * @property   array $post
 23:  * @property   array $files
 24:  * @property   string $method
 25:  * @package Nette\Application
 26:  */
 27: final class PresenterRequest extends FreezableObject
 28: {
 29:     /** method */
 30:     const FORWARD = 'FORWARD';
 31: 
 32:     /** flag */
 33:     const SECURED = 'secured';
 34: 
 35:     /** flag */
 36:     const RESTORED = 'restored';
 37: 
 38:     /** @var string */
 39:     private $method;
 40: 
 41:     /** @var array */
 42:     private $flags = array();
 43: 
 44:     /** @var string */
 45:     private $name;
 46: 
 47:     /** @var array */
 48:     private $params;
 49: 
 50:     /** @var array */
 51:     private $post;
 52: 
 53:     /** @var array */
 54:     private $files;
 55: 
 56: 
 57: 
 58:     /**
 59:      * @param  string  fully qualified presenter name (module:module:presenter)
 60:      * @param  string  method
 61:      * @param  array   variables provided to the presenter usually via URL
 62:      * @param  array   variables provided to the presenter via POST
 63:      * @param  array   all uploaded files
 64:      */
 65:     public function __construct($name, $method, array $params, array $post = array(), array $files = array(), array $flags = array())
 66:     {
 67:         $this->name = $name;
 68:         $this->method = $method;
 69:         $this->params = $params;
 70:         $this->post = $post;
 71:         $this->files = $files;
 72:         $this->flags = $flags;
 73:     }
 74: 
 75: 
 76: 
 77:     /**
 78:      * Sets the presenter name.
 79:      * @param  string
 80:      * @return PresenterRequest  provides a fluent interface
 81:      */
 82:     public function setPresenterName($name)
 83:     {
 84:         $this->updating();
 85:         $this->name = $name;
 86:         return $this;
 87:     }
 88: 
 89: 
 90: 
 91:     /**
 92:      * Retrieve the presenter name.
 93:      * @return string
 94:      */
 95:     public function getPresenterName()
 96:     {
 97:         return $this->name;
 98:     }
 99: 
100: 
101: 
102:     /**
103:      * Sets variables provided to the presenter.
104:      * @param  array
105:      * @return PresenterRequest  provides a fluent interface
106:      */
107:     public function setParameters(array $params)
108:     {
109:         $this->updating();
110:         $this->params = $params;
111:         return $this;
112:     }
113: 
114: 
115: 
116:     /**
117:      * Returns all variables provided to the presenter (usually via URL).
118:      * @return array
119:      */
120:     public function getParameters()
121:     {
122:         return $this->params;
123:     }
124: 
125: 
126: 
127:     /** @deprecated */
128:     function setParams(array $params)
129:     {
130:         trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
131:         return $this->setParameters($params);
132:     }
133: 
134: 
135: 
136:     /** @deprecated */
137:     function getParams()
138:     {
139:         trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
140:         return $this->getParameters();
141:     }
142: 
143: 
144: 
145:     /**
146:      * Sets variables provided to the presenter via POST.
147:      * @param  array
148:      * @return PresenterRequest  provides a fluent interface
149:      */
150:     public function setPost(array $params)
151:     {
152:         $this->updating();
153:         $this->post = $params;
154:         return $this;
155:     }
156: 
157: 
158: 
159:     /**
160:      * Returns all variables provided to the presenter via POST.
161:      * @return array
162:      */
163:     public function getPost()
164:     {
165:         return $this->post;
166:     }
167: 
168: 
169: 
170:     /**
171:      * Sets all uploaded files.
172:      * @param  array
173:      * @return PresenterRequest  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 PresenterRequest  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 PresenterRequest  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.0 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.7.0