lithium\action\Response::render PHP 메소드

render() 공개 메소드

Reponses which have a Location header set are indicating a redirect, will get their status code automatically adjusted to 302 (Found/Moved Temporarily) in case the status code before was 200 (OK). This is to allow easy redirects by setting just the Location header and is assumed to be the original intent of the user. On responses with status codes 204 (No Content) and 302 (Found) a message body - even if one is set - will never be send. These status codes either don't have a message body as per their nature or they are ignored and can thus be omitted for performance reasons.
public render ( ) : void
리턴 void
    public function render()
    {
        $code = null;
        if (isset($this->headers['location']) || isset($this->headers['Location'])) {
            if ($this->status['code'] === 200) {
                $this->status(302);
            }
            $code = $this->status['code'];
        }
        if ($cookies = $this->_cookies()) {
            $this->headers('Set-Cookie', $cookies);
        }
        $this->_writeHeaders($this->status() ?: $this->status(500));
        $this->_writeHeaders($this->headers(), $code);
        if ($this->status['code'] === 302 || $this->status['code'] === 204) {
            return;
        }
        foreach ($this->body(null, $this->_config) as $chunk) {
            echo $chunk;
        }
    }

Usage Example

예제 #1
0
 public function render()
 {
     $this->testHeaders = array();
     parent::render();
     $this->headers = array();
 }