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:      * @param  array   flags
 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 setParameters(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 getParameters()
122:     {
123:         return $this->params;
124:     }
125: 
126: 
127: 
128:     /** @deprecated */
129:     function setParams(array $params)
130:     {
131:         trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
132:         return $this->setParameters($params);
133:     }
134: 
135: 
136: 
137:     /** @deprecated */
138:     function getParams()
139:     {
140:         trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
141:         return $this->getParameters();
142:     }
143: 
144: 
145: 
146:     /**
147:      * Sets variables provided to the presenter via POST.
148:      * @param  array
149:      * @return PresenterRequest  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:      * @param  array
174:      * @return PresenterRequest  provides a fluent interface
175:      */
176:     public function setFiles(array $files)
177:     {
178:         $this->updating();
179:         $this->files = $files;
180:         return $this;
181:     }
182: 
183: 
184: 
185:     /**
186:      * Returns all uploaded files.
187:      * @return array
188:      */
189:     public function getFiles()
190:     {
191:         return $this->files;
192:     }
193: 
194: 
195: 
196:     /**
197:      * Sets the method.
198:      * @param  string
199:      * @return PresenterRequest  provides a fluent interface
200:      */
201:     public function setMethod($method)
202:     {
203:         $this->method = $method;
204:         return $this;
205:     }
206: 
207: 
208: 
209:     /**
210:      * Returns the method.
211:      * @return string
212:      */
213:     public function getMethod()
214:     {
215:         return $this->method;
216:     }
217: 
218: 
219: 
220:     /**
221:      * Checks if the method is the given one.
222:      * @param  string
223:      * @return bool
224:      */
225:     public function isMethod($method)
226:     {
227:         return strcasecmp($this->method, $method) === 0;
228:     }
229: 
230: 
231: 
232:     /**
233:      * Checks if the method is POST.
234:      * @return bool
235:      */
236:     public function isPost()
237:     {
238:         return strcasecmp($this->method, 'post') === 0;
239:     }
240: 
241: 
242: 
243:     /**
244:      * Sets the flag.
245:      * @param  string
246:      * @param  bool
247:      * @return PresenterRequest  provides a fluent interface
248:      */
249:     public function setFlag($flag, $value = TRUE)
250:     {
251:         $this->updating();
252:         $this->flags[$flag] = (bool) $value;
253:         return $this;
254:     }
255: 
256: 
257: 
258:     /**
259:      * Checks the flag.
260:      * @param  string
261:      * @return bool
262:      */
263:     public function hasFlag($flag)
264:     {
265:         return !empty($this->flags[$flag]);
266:     }
267: 
268: }
269: 
Nette Framework 2.0.5 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.7.0