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