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

Classes

  • Application
  • PresenterFactory
  • Request

Interfaces

  • IPresenter
  • IPresenterFactory
  • IResponse
  • IRouter

Exceptions

  • AbortException
  • ApplicationException
  • BadRequestException
  • ForbiddenRequestException
  • InvalidPresenterException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (https://nette.org)
  5:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
  6:  */
  7: 
  8: namespace Nette\Application;
  9: 
 10: use Nette;
 11: 
 12: 
 13: /**
 14:  * Presenter request. Immutable object.
 15:  *
 16:  * @author     David Grudl
 17:  *
 18:  * @property   string $presenterName
 19:  * @property   array $parameters
 20:  * @property   array $post
 21:  * @property   array $files
 22:  * @property   string $method
 23:  */
 24: class Request extends Nette\FreezableObject
 25: {
 26:     /** method */
 27:     const FORWARD = 'FORWARD';
 28: 
 29:     /** flag */
 30:     const SECURED = 'secured';
 31: 
 32:     /** flag */
 33:     const RESTORED = 'restored';
 34: 
 35:     /** @var string */
 36:     private $method;
 37: 
 38:     /** @var array */
 39:     private $flags = array();
 40: 
 41:     /** @var string */
 42:     private $name;
 43: 
 44:     /** @var array */
 45:     private $params;
 46: 
 47:     /** @var array */
 48:     private $post;
 49: 
 50:     /** @var array */
 51:     private $files;
 52: 
 53: 
 54:     /**
 55:      * @param  string  fully qualified presenter name (module:module:presenter)
 56:      * @param  string  method
 57:      * @param  array   variables provided to the presenter usually via URL
 58:      * @param  array   variables provided to the presenter via POST
 59:      * @param  array   all uploaded files
 60:      * @param  array   flags
 61:      */
 62:     public function __construct($name, $method, array $params, array $post = array(), array $files = array(), array $flags = array())
 63:     {
 64:         $this->name = $name;
 65:         $this->method = $method;
 66:         $this->params = $params;
 67:         $this->post = $post;
 68:         $this->files = $files;
 69:         $this->flags = $flags;
 70:     }
 71: 
 72: 
 73:     /**
 74:      * Sets the presenter name.
 75:      * @param  string
 76:      * @return self
 77:      */
 78:     public function setPresenterName($name)
 79:     {
 80:         $this->updating();
 81:         $this->name = $name;
 82:         return $this;
 83:     }
 84: 
 85: 
 86:     /**
 87:      * Retrieve the presenter name.
 88:      * @return string
 89:      */
 90:     public function getPresenterName()
 91:     {
 92:         return $this->name;
 93:     }
 94: 
 95: 
 96:     /**
 97:      * Sets variables provided to the presenter.
 98:      * @return self
 99:      */
100:     public function setParameters(array $params)
101:     {
102:         $this->updating();
103:         $this->params = $params;
104:         return $this;
105:     }
106: 
107: 
108:     /**
109:      * Returns all variables provided to the presenter (usually via URL).
110:      * @return array
111:      */
112:     public function getParameters()
113:     {
114:         return $this->params;
115:     }
116: 
117: 
118:     /** @deprecated */
119:     function setParams(array $params)
120:     {
121:         trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
122:         return $this->setParameters($params);
123:     }
124: 
125: 
126:     /** @deprecated */
127:     function getParams()
128:     {
129:         trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
130:         return $this->getParameters();
131:     }
132: 
133: 
134:     /**
135:      * Sets variables provided to the presenter via POST.
136:      * @return self
137:      */
138:     public function setPost(array $params)
139:     {
140:         $this->updating();
141:         $this->post = $params;
142:         return $this;
143:     }
144: 
145: 
146:     /**
147:      * Returns all variables provided to the presenter via POST.
148:      * @return array
149:      */
150:     public function getPost()
151:     {
152:         return $this->post;
153:     }
154: 
155: 
156:     /**
157:      * Sets all uploaded files.
158:      * @return self
159:      */
160:     public function setFiles(array $files)
161:     {
162:         $this->updating();
163:         $this->files = $files;
164:         return $this;
165:     }
166: 
167: 
168:     /**
169:      * Returns all uploaded files.
170:      * @return array
171:      */
172:     public function getFiles()
173:     {
174:         return $this->files;
175:     }
176: 
177: 
178:     /**
179:      * Sets the method.
180:      * @param  string
181:      * @return self
182:      */
183:     public function setMethod($method)
184:     {
185:         $this->method = $method;
186:         return $this;
187:     }
188: 
189: 
190:     /**
191:      * Returns the method.
192:      * @return string
193:      */
194:     public function getMethod()
195:     {
196:         return $this->method;
197:     }
198: 
199: 
200:     /**
201:      * Checks if the method is the given one.
202:      * @param  string
203:      * @return bool
204:      */
205:     public function isMethod($method)
206:     {
207:         return strcasecmp($this->method, $method) === 0;
208:     }
209: 
210: 
211:     /**
212:      * Checks if the method is POST.
213:      * @return bool
214:      */
215:     public function isPost()
216:     {
217:         return strcasecmp($this->method, 'post') === 0;
218:     }
219: 
220: 
221:     /**
222:      * Sets the flag.
223:      * @param  string
224:      * @param  bool
225:      * @return self
226:      */
227:     public function setFlag($flag, $value = TRUE)
228:     {
229:         $this->updating();
230:         $this->flags[$flag] = (bool) $value;
231:         return $this;
232:     }
233: 
234: 
235:     /**
236:      * Checks the flag.
237:      * @param  string
238:      * @return bool
239:      */
240:     public function hasFlag($flag)
241:     {
242:         return !empty($this->flags[$flag]);
243:     }
244: 
245: }
246: 
Nette 2.0 API documentation generated by ApiGen 2.8.0