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

Classes

Interfaces

Exceptions

  • Overview
  • Package
  • 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:  * @package Nette\Application
  7:  */
  8: 
  9: 
 10: 
 11: /**
 12:  * Presenter request. Immutable object.
 13:  *
 14:  * @author     David Grudl
 15:  *
 16:  * @property   string $presenterName
 17:  * @property   array $parameters
 18:  * @property   array $post
 19:  * @property   array $files
 20:  * @property   string $method
 21:  * @package Nette\Application
 22:  */
 23: class PresenterRequest extends FreezableObject
 24: {
 25:     /** method */
 26:     const FORWARD = 'FORWARD';
 27: 
 28:     /** flag */
 29:     const SECURED = 'secured';
 30: 
 31:     /** flag */
 32:     const RESTORED = 'restored';
 33: 
 34:     /** @var string */
 35:     private $method;
 36: 
 37:     /** @var array */
 38:     private $flags = array();
 39: 
 40:     /** @var string */
 41:     private $name;
 42: 
 43:     /** @var array */
 44:     private $params;
 45: 
 46:     /** @var array */
 47:     private $post;
 48: 
 49:     /** @var array */
 50:     private $files;
 51: 
 52: 
 53:     /**
 54:      * @param  string  fully qualified presenter name (module:module:presenter)
 55:      * @param  string  method
 56:      * @param  array   variables provided to the presenter usually via URL
 57:      * @param  array   variables provided to the presenter via POST
 58:      * @param  array   all uploaded files
 59:      * @param  array   flags
 60:      */
 61:     public function __construct($name, $method, array $params, array $post = array(), array $files = array(), array $flags = array())
 62:     {
 63:         $this->name = $name;
 64:         $this->method = $method;
 65:         $this->params = $params;
 66:         $this->post = $post;
 67:         $this->files = $files;
 68:         $this->flags = $flags;
 69:     }
 70: 
 71: 
 72:     /**
 73:      * Sets the presenter name.
 74:      * @param  string
 75:      * @return self
 76:      */
 77:     public function setPresenterName($name)
 78:     {
 79:         $this->updating();
 80:         $this->name = $name;
 81:         return $this;
 82:     }
 83: 
 84: 
 85:     /**
 86:      * Retrieve the presenter name.
 87:      * @return string
 88:      */
 89:     public function getPresenterName()
 90:     {
 91:         return $this->name;
 92:     }
 93: 
 94: 
 95:     /**
 96:      * Sets variables provided to the presenter.
 97:      * @return self
 98:      */
 99:     public function setParameters(array $params)
100:     {
101:         $this->updating();
102:         $this->params = $params;
103:         return $this;
104:     }
105: 
106: 
107:     /**
108:      * Returns all variables provided to the presenter (usually via URL).
109:      * @return array
110:      */
111:     public function getParameters()
112:     {
113:         return $this->params;
114:     }
115: 
116: 
117:     /** @deprecated */
118:     function setParams(array $params)
119:     {
120:         trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
121:         return $this->setParameters($params);
122:     }
123: 
124: 
125:     /** @deprecated */
126:     function getParams()
127:     {
128:         trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
129:         return $this->getParameters();
130:     }
131: 
132: 
133:     /**
134:      * Sets variables provided to the presenter via POST.
135:      * @return self
136:      */
137:     public function setPost(array $params)
138:     {
139:         $this->updating();
140:         $this->post = $params;
141:         return $this;
142:     }
143: 
144: 
145:     /**
146:      * Returns all variables provided to the presenter via POST.
147:      * @return array
148:      */
149:     public function getPost()
150:     {
151:         return $this->post;
152:     }
153: 
154: 
155:     /**
156:      * Sets all uploaded files.
157:      * @return self
158:      */
159:     public function setFiles(array $files)
160:     {
161:         $this->updating();
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
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
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:      * Checks if the method is POST.
212:      * @return bool
213:      */
214:     public function isPost()
215:     {
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->updating();
229:         $this->flags[$flag] = (bool) $value;
230:         return $this;
231:     }
232: 
233: 
234:     /**
235:      * Checks the flag.
236:      * @param  string
237:      * @return bool
238:      */
239:     public function hasFlag($flag)
240:     {
241:         return !empty($this->flags[$flag]);
242:     }
243: 
244: }
245: 
Nette Framework 2.0.18 (for PHP 5.2, un-prefixed) API documentation generated by ApiGen 2.8.0