Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- /**
- * ILLI
- *
- * @category ILLI_Core_Web
- * @package ILLI
- * @link http://illi.be
- * @license http://l.illi.be
- * @copyright ILLI Conference
- */
- NAMESPACE ILLI\Core\Web;
- USE ILLI\Core\Virtual\Member\iField AS iField;
- USE ILLI\Core\Virtual\Member\tField AS tField;
- USE ILLI\Core\Web\Data\Response\Headers AS Headers;
- USE \ILLI\Core\Web\Data\Response\RedirectAfterPost AS RedirectAfterPost;
- /**
- * ILLI Web Response
- *
- * @category ILLI_Core_Web
- * @package ILLI
- * @subpackage Core\Web
- * @namespace ILLI\Core\Web
- * @link http://illi.be
- * @license http://l.illi.be
- * @copyright ILLI Conference
- * @since 2.0.1
- * @version 3.0.1
- */
- CLASS Response EXTENDS aWeb
- {
- USE tField
- {
- tField_template__get as PUBLIC __get;
- tField_template__set as PUBLIC __set;
- }
- public function __construct(array $agents = [])
- {
- $this->tField_define
- (
- 'Headers', 'ILLI\Core\Web\Data\Response\Headers',
- [
- iField::PROP_INIT => new Headers,
- iField::PROP_PRIVATE_SET => FALSE,
- iField::PROP_PRIVATE_GET => FALSE,
- iField::PROP_ON_GET => function(array $data)
- {
- $header = $data[iField::CALLBACK_PROP_CONTAINS];
- $header->offsetSet('Content-Type', $this->tField_get('contentType'));
- if(FALSE === $this->tField_get('isCacheEnabled'))
- {
- $header->offsetSet('Pragma', 'no-cache');
- $header->offsetSet('Expires', '1');
- $header->offsetSet('Cache-Control',
- [
- 'no-store, no-cache, must-revalidate',
- 'post-check=0, pre-check=0'
- ]);
- }
- if(TRUE === $this->tField_get('isRedirect'))
- {
- $header->offsetSet('Location', $this->tField_get('Redirect')->Uri->originalString);
- }
- $data[iField::CALLBACK_PROP_CONTAINS] = $header;
- return $data;
- }
- ],
- iField::DEBUG_CONTAINS
- )
- ->tField_define
- (
- 'httpVersion', 'float',
- [
- iField::PROP_INIT => 1.1,
- iField::PROP_PRIVATE_SET => TRUE,
- iField::PROP_PRIVATE_GET => TRUE,
- iField::PROP_ON_SET => function(array $data)
- {
- $version = $data[iField::CALLBACK_PROP_NEW];
- if($version !== 1.1
- && $version !== 1.0)
- throw new \Exception('HTTP version '.$version.' not recognized.');
- return $data;
- }
- ],
- iField::DEBUG_CONTAINS
- )
- ->tField_define
- (
- 'contentType', 'string',
- [
- iField::PROP_INIT => 'text/html',
- iField::PROP_PRIVATE_SET => FALSE,
- iField::PROP_PRIVATE_GET => FALSE,
- iField::PROP_ON_SET => function(array $data)
- {
- $value = $data[iField::CALLBACK_PROP_NEW];
- $this->tField_get('Headers')->offsetSet('Content-Type', $value);
- return $data;
- }
- ],
- iField::DEBUG_CONTAINS
- )
- ->tField_define
- (
- 'isCacheEnabled', 'boolean',
- [
- iField::PROP_INIT => TRUE,
- iField::PROP_PRIVATE_SET => FALSE,
- iField::PROP_PRIVATE_GET => FALSE
- ],
- iField::DEBUG_CONTAINS
- )
- ->tField_define
- (
- 'isRedirect', 'boolean',
- [
- iField::PROP_INIT => FALSE,
- iField::PROP_PRIVATE_SET => FALSE,
- iField::PROP_PRIVATE_GET => FALSE
- ],
- iField::DEBUG_CONTAINS
- )
- ->tField_define
- (
- 'Redirect', '\ILLI\Core\Web\Data\Response\Redirect',
- [
- iField::PROP_INIT => NULL,
- iField::PROP_PRIVATE_SET => FALSE,
- iField::PROP_PRIVATE_GET => FALSE,
- iField::PROP_SYNCH =>
- [
- 'isRedirect' => function(Redirect $__Redirect)
- {
- return TRUE;
- },
- ]
- ],
- iField::DEBUG_CONTAINS
- )
- ->tField_define
- (
- 'RedirectAfterPost', '\ILLI\Core\Web\Data\Response\RedirectAfterPost',
- [
- iField::PROP_INIT => NULL,
- iField::PROP_PRIVATE_SET => FALSE,
- iField::PROP_PRIVATE_GET => FALSE,
- iField::PROP_SYNCH =>
- [
- 'Redirect' => function(RedirectAfterPost $__RedirectAfterPost)
- {
- return $__RedirectAfterPost;
- },
- 'isCacheEnabled' => function(RedirectAfterPost $__RedirectAfterPost)
- {
- return FALSE;
- },
- 'isRedirect' => function(RedirectAfterPost $__RedirectAfterPost)
- {
- return TRUE;
- }
- ]
- ],
- iField::DEBUG_CONTAINS
- );
- }
- }
- ?>
- object(ILLI\Core\Web\Response)#15 (4) {
- ["__tField":protected]=>
- array(7) {
- ["Headers"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Web\Data\Response\Headers)#24 (7) {
- ["__flag":protected]=>
- int(34)
- ["__data":protected]=>
- array(5) {
- ["Content-Type"]=>
- string(9) "text/html"
- ["Pragma"]=>
- string(8) "no-cache"
- ["Expires"]=>
- string(1) "1"
- ["Cache-Control"]=>
- array(2) {
- [0]=>
- string(35) "no-store, no-cache, must-revalidate"
- [1]=>
- string(25) "post-check=0, pre-check=0"
- }
- ["Location"]=>
- string(16) "http://localhost"
- }
- ["__tCollectionField_flag":"ILLI\Core\Data\FieldCollection":private]=>
- int(34)
- ["__tField":protected]=>
- array(0) {
- }
- ["__tField_LockRegistration":"ILLI\Core\Data\FieldCollection":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Data\FieldCollection":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Data\FieldCollection":private]=>
- string(32) "0000000068284284000000003f42da20"
- }
- }
- ["httpVersion"]=>
- array(1) {
- ["contains"]=>
- &float(1.1)
- }
- ["contentType"]=>
- array(1) {
- ["contains"]=>
- &string(9) "text/html"
- }
- ["isCacheEnabled"]=>
- array(1) {
- ["contains"]=>
- &bool(false)
- }
- ["isRedirect"]=>
- array(1) {
- ["contains"]=>
- &bool(true)
- }
- ["Redirect"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Web\Data\Response\RedirectAfterPost)#46 (4) {
- ["__tField":protected]=>
- array(3) {
- ["Uri"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Uri\Uri)#49 (4) {
- ["__tField":protected]=>
- array(4) {
- ["originalString"]=>
- array(1) {
- ["contains"]=>
- &string(16) "http://localhost"
- }
- ["Query"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Uri\Query)#53 (4) {
- ["__tField":protected]=>
- array(3) {
- ["query"]=>
- array(1) {
- ["contains"]=>
- &array(0) {
- }
- }
- ["string"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["escaped"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Query":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Query":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Query":private]=>
- string(32) "00000000682842a9000000003f42da20"
- }
- }
- ["Authority"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Uri\Authority)#66 (4) {
- ["__tField":protected]=>
- array(3) {
- ["username"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["password"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["passport"]=>
- array(1) {
- ["contains"]=>
- &string(1) "1"
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Authority":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Authority":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Authority":private]=>
- string(32) "00000000682842de000000003f42da20"
- }
- }
- ["Path"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Uri\Path)#80 (4) {
- ["__tField":protected]=>
- array(4) {
- ["absolutePath"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["dirName"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["baseName"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["extension"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Path":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Path":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Path":private]=>
- string(32) "00000000682842cc000000003f42da20"
- }
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Uri":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Uri":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Uri":private]=>
- string(32) "00000000682842ad000000003f42da20"
- }
- }
- ["statusCode"]=>
- array(1) {
- ["contains"]=>
- &int(303)
- }
- ["statusText"]=>
- array(1) {
- ["contains"]=>
- &string(9) "See Other"
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Web\Data\Response\Redirect":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Web\Data\Response\Redirect":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Web\Data\Response\Redirect":private]=>
- string(32) "00000000682842b2000000003f42da20"
- }
- }
- ["RedirectAfterPost"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Web\Data\Response\RedirectAfterPost)#46 (4) {
- ["__tField":protected]=>
- array(3) {
- ["Uri"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Uri\Uri)#49 (4) {
- ["__tField":protected]=>
- array(4) {
- ["originalString"]=>
- array(1) {
- ["contains"]=>
- &string(16) "http://localhost"
- }
- ["Query"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Uri\Query)#53 (4) {
- ["__tField":protected]=>
- array(3) {
- ["query"]=>
- array(1) {
- ["contains"]=>
- &array(0) {
- }
- }
- ["string"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["escaped"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Query":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Query":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Query":private]=>
- string(32) "00000000682842a9000000003f42da20"
- }
- }
- ["Authority"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Uri\Authority)#66 (4) {
- ["__tField":protected]=>
- array(3) {
- ["username"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["password"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["passport"]=>
- array(1) {
- ["contains"]=>
- &string(1) "1"
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Authority":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Authority":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Authority":private]=>
- string(32) "00000000682842de000000003f42da20"
- }
- }
- ["Path"]=>
- array(1) {
- ["contains"]=>
- &object(ILLI\Core\Uri\Path)#80 (4) {
- ["__tField":protected]=>
- array(4) {
- ["absolutePath"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["dirName"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["baseName"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- ["extension"]=>
- array(1) {
- ["contains"]=>
- &string(0) ""
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Path":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Path":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Path":private]=>
- string(32) "00000000682842cc000000003f42da20"
- }
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Uri":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Uri":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Uri":private]=>
- string(32) "00000000682842ad000000003f42da20"
- }
- }
- ["statusCode"]=>
- array(1) {
- ["contains"]=>
- &int(303)
- }
- ["statusText"]=>
- array(1) {
- ["contains"]=>
- &string(9) "See Other"
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Web\Data\Response\Redirect":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Web\Data\Response\Redirect":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Web\Data\Response\Redirect":private]=>
- string(32) "00000000682842b2000000003f42da20"
- }
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Web\Response":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Web\Response":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Web\Response":private]=>
- string(32) "0000000068284293000000003f42da20"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement