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:  * Presenter request. Immutable object.
 19:  *
 20:  * @author     David Grudl
 21:  *
 22:  * @property   string $presenterName
 23:  * @property   array $parameters
 24:  * @property   array $post
 25:  * @property   array $files
 26:  * @property   string $method
 27:  */
 28: final class Request extends Nette\FreezableObject
 29: {
 30:     /** method */
 31:     const FORWARD = 'FORWARD';
 32: 
 33:     /** flag */
 34:     const SECURED = 'secured';
 35: 
 36:     /** flag */
 37:     const RESTORED = 'restored';
 38: 
 39:     /** @var string */
 40:     private $method;
 41: 
 42:     /** @var array */
 43:     private $flags = array();
 44: 
 45:     /** @var string */
 46:     private $name;
 47: 
 48:     /** @var array */
 49:     private $params;
 50: 
 51:     /** @var array */
 52:     private $post;
 53: 
 54:     /** @var array */
 55:     private $files;
 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:      * Sets the presenter name.
 79:      * @param  string
 80:      * @return self
 81:      */
 82:     public function setPresenterName($name)
 83:     {
 84:         $this->updating();
 85:         $this->name = $name;
 86:         return $this;
 87:     }
 88: 
 89: 
 90:     /**
 91:      * Retrieve the presenter name.
 92:      * @return string
 93:      */
 94:     public function getPresenterName()
 95:     {
 96:         return $this->name;
 97:     }
 98: 
 99: 
100:     /**
101:      * Sets variables provided to the presenter.
102:      * @return self
103:      */
104:     public function setParameters(array $params)
105:     {
106:         $this->updating();
107:         $this->params = $params;
108:         return $this;
109:     }
110: 
111: 
112:     /**
113:      * Returns all variables provided to the presenter (usually via URL).
114:      * @return array
115:      */
116:     public function getParameters()
117:     {
118:         return $this->params;
119:     }
120: 
121: 
122:     /** @deprecated */
123:     function setParams(array $params)
124:     {
125:         trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
126:         return $this->setParameters($params);
127:     }
128: 
129: 
130:     /** @deprecated */
131:     function getParams()
132:     {
133:         trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
134:         return $this->getParameters();
135:     }
136: 
137: 
138:     /**
139:      * Sets variables provided to the presenter via POST.
140:      * @return self
141:      */
142:     public function setPost(array $params)
143:     {
144:         $this->updating();
145:         $this->post = $params;
146:         return $this;
147:     }
148: 
149: 
150:     /**
151:      * Returns all variables provided to the presenter via POST.
152:      * @return array
153:      */
154:     public function getPost()
155:     {
156:         return $this->post;
157:     }
158: 
159: 
160:     /**
161:      * Sets all uploaded files.
162:      * @return self
163:      */
164:     public function setFiles(array $files)
165:     {
166:         $this->updating();
167:         $this->files = $files;
168:         return $this;
169:     }
170: 
171: 
172:     /**
173:      * Returns all uploaded files.
174:      * @return array
175:      */
176:     public function getFiles()
177:     {
178:         return $this->files;
179:     }
180: 
181: 
182:     /**
183:      * Sets the method.
184:      * @param  string
185:      * @return self
186:      */
187:     public function setMethod($method)
188:     {
189:         $this->method = $method;
190:         return $this;
191:     }
192: 
193: 
194:     /**
195:      * Returns the method.
196:      * @return string
197:      */
198:     public function getMethod()
199:     {
200:         return $this->method;
201:     }
202: 
203: 
204:     /**
205:      * Checks if the method is the given one.
206:      * @param  string
207:      * @return bool
208:      */
209:     public function isMethod($method)
210:     {
211:         return strcasecmp($this->method, $method) === 0;
212:     }
213: 
214: 
215:     /**
216:      * Checks if the method is POST.
217:      * @return bool
218:      */
219:     public function isPost()
220:     {
221:         return strcasecmp($this->method, 'post') === 0;
222:     }
223: 
224: 
225:     /**
226:      * Sets the flag.
227:      * @param  string
228:      * @param  bool
229:      * @return self
230:      */
231:     public function setFlag($flag, $value = TRUE)
232:     {
233:         $this->updating();
234:         $this->flags[$flag] = (bool) $value;
235:         return $this;
236:     }
237: 
238: 
239:     /**
240:      * Checks the flag.
241:      * @param  string
242:      * @return bool
243:      */
244:     public function hasFlag($flag)
245:     {
246:         return !empty($this->flags[$flag]);
247:     }
248: 
249: }
250: 
Nette Framework 2.0.11 API API documentation generated by ApiGen 2.8.0