Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationLatte
      • ApplicationTracy
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsLatte
      • Framework
      • HttpTracy
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • 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

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 (https://davidgrudl.com)
  6:  */
  7: 
  8: namespace Nette\Application;
  9: 
 10: use Nette;
 11: 
 12: 
 13: /**
 14:  * Presenter request.
 15:  *
 16:  * @author     David Grudl
 17:  *
 18:  * @property   array $parameters
 19:  * @property   array $post
 20:  * @property   array $files
 21:  * @property   string|NULL $method
 22:  */
 23: class Request extends Nette\Object
 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|NULL */
 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 = NULL, array $params = array(), 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->name = $name;
 80:         return $this;
 81:     }
 82: 
 83: 
 84:     /**
 85:      * Retrieve the presenter name.
 86:      * @return string
 87:      */
 88:     public function getPresenterName()
 89:     {
 90:         return $this->name;
 91:     }
 92: 
 93: 
 94:     /**
 95:      * Sets variables provided to the presenter.
 96:      * @return self
 97:      */
 98:     public function setParameters(array $params)
 99:     {
100:         $this->params = $params;
101:         return $this;
102:     }
103: 
104: 
105:     /**
106:      * Returns all variables provided to the presenter (usually via URL).
107:      * @return array
108:      */
109:     public function getParameters()
110:     {
111:         return $this->params;
112:     }
113: 
114: 
115:     /**
116:      * Sets variables provided to the presenter via POST.
117:      * @return self
118:      */
119:     public function setPost(array $params)
120:     {
121:         $this->post = $params;
122:         return $this;
123:     }
124: 
125: 
126:     /**
127:      * Returns all variables provided to the presenter via POST.
128:      * @return array
129:      */
130:     public function getPost()
131:     {
132:         return $this->post;
133:     }
134: 
135: 
136:     /**
137:      * Sets all uploaded files.
138:      * @return self
139:      */
140:     public function setFiles(array $files)
141:     {
142:         $this->files = $files;
143:         return $this;
144:     }
145: 
146: 
147:     /**
148:      * Returns all uploaded files.
149:      * @return array
150:      */
151:     public function getFiles()
152:     {
153:         return $this->files;
154:     }
155: 
156: 
157:     /**
158:      * Sets the method.
159:      * @param  string|NULL
160:      * @return self
161:      */
162:     public function setMethod($method)
163:     {
164:         $this->method = $method;
165:         return $this;
166:     }
167: 
168: 
169:     /**
170:      * Returns the method.
171:      * @return string|NULL
172:      */
173:     public function getMethod()
174:     {
175:         return $this->method;
176:     }
177: 
178: 
179:     /**
180:      * Checks if the method is the given one.
181:      * @param  string
182:      * @return bool
183:      */
184:     public function isMethod($method)
185:     {
186:         return strcasecmp($this->method, $method) === 0;
187:     }
188: 
189: 
190:     /**
191:      * Checks if the method is POST.
192:      * @return bool
193:      */
194:     public function isPost()
195:     {
196:         return strcasecmp($this->method, 'post') === 0;
197:     }
198: 
199: 
200:     /**
201:      * Sets the flag.
202:      * @param  string
203:      * @param  bool
204:      * @return self
205:      */
206:     public function setFlag($flag, $value = TRUE)
207:     {
208:         $this->flags[$flag] = (bool) $value;
209:         return $this;
210:     }
211: 
212: 
213:     /**
214:      * Checks the flag.
215:      * @param  string
216:      * @return bool
217:      */
218:     public function hasFlag($flag)
219:     {
220:         return !empty($this->flags[$flag]);
221:     }
222: 
223: }
224: 
Nette 2.2 API documentation generated by ApiGen 2.8.0