lithium\action\Request::_init PHP Méthode

_init() protected méthode

Note that only beginning with PHP 5.6 STDIN can be opened/read and closed more than once.
See also: lithium\action\Request::_parseFiles()
protected _init ( )
    protected function _init()
    {
        parent::_init();
        $mobile = array('iPhone', 'MIDP', 'AvantGo', 'BlackBerry', 'J2ME', 'Opera Mini', 'DoCoMo', 'NetFront', 'Nokia', 'PalmOS', 'PalmSource', 'portalmmm', 'Plucker', 'ReqwirelessWeb', 'iPod', 'SonyEricsson', 'Symbian', 'UP\\.Browser', 'Windows CE', 'Xiino', 'Android');
        if (!empty($this->_config['detectors']['mobile'][1])) {
            $mobile = array_merge($mobile, (array) $this->_config['detectors']['mobile'][1]);
        }
        $this->_detectors['mobile'][1] = $mobile;
        $this->data = (array) $this->_config['data'];
        if (isset($this->data['_method'])) {
            $this->_computed['HTTP_X_HTTP_METHOD_OVERRIDE'] = strtoupper($this->data['_method']);
            unset($this->data['_method']);
        }
        $type = $this->type($this->_config['type'] ?: $this->env('CONTENT_TYPE'));
        $this->method = strtoupper($this->env('REQUEST_METHOD'));
        $hasBody = in_array($this->method, array('POST', 'PUT', 'PATCH'));
        if (!$this->body && $hasBody && $type !== 'html') {
            $this->_stream = $this->_stream ?: fopen('php://input', 'r');
            $this->body = stream_get_contents($this->_stream);
            fclose($this->_stream);
        }
        if (!$this->data && $this->body) {
            $this->data = $this->body(null, array('decode' => true, 'encode' => false));
        }
        $this->body = $this->data;
        if ($this->_config['globals'] && !empty($_FILES)) {
            $this->data = Set::merge($this->data, $this->_parseFiles($_FILES));
        }
    }

Usage Example

 protected function _init()
 {
     $safari = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7) AppleWebKit/534.48.3 ';
     $safari .= '(KHTML, like Gecko) Version/5.1 Safari/534.48.3';
     parent::_init();
     $this->_env = array('FCGI_ROLE' => 'RESPONDER', 'PATH_INFO' => '', 'PATH_TRANSLATED' => '/lithium/app/webroot/index.php', 'QUERY_STRING' => '', 'REQUEST_METHOD' => 'GET', 'CONTENT_TYPE' => '', 'CONTENT_LENGTH' => '', 'SCRIPT_NAME' => '/index.php', 'SCRIPT_FILENAME' => '/lithium/app/webroot/index.php', 'REQUEST_URI' => '/', 'DOCUMENT_URI' => '/index.php', 'DOCUMENT_ROOT' => '/lithium/app/webroot', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_PORT' => '52987', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'SERVER_NAME' => 'sandbox.local', 'HTTP_HOST' => 'sandbox.local', 'HTTP_USER_AGENT' => $safari, 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_CONNECTION' => 'keep-alive', 'PHP_SELF' => '/index.php');
 }
All Usage Examples Of lithium\action\Request::_init