Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • none
  • Tracy
    • Bridges
      • Nette

Classes

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