Yaf_Controller_Abstract::getResponse
PHP Manual
PHP Manual»Yaf_Controller_Abstract»Yaf_Controller_Abstract::getResponse

Yaf_Controller_Abstract::getResponse

(Yaf >=1.0.0)

Yaf_Controller_Abstract::getResponse — Retrieve current response object

Опис

public function Yaf_Controller_Abstract::getResponse(): ?Yaf_Response_Abstract

Returns the Yaf_Response_Abstract instance associated with this controller.

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

A Yaf_Response_Abstract instance, or null if no response is available.

Приклади

Приклад #1 Yaf_Controller_Abstract::getResponse() example

<?php
class ProductController extends Yaf_Controller_Abstract
{
    public function apiAction() {
        // build the answer ourselves, no template needed
        Yaf_Dispatcher::getInstance()->disableView();

        $response = $this->getResponse();
        $response->setHeader("Content-Type", "application/json");
        $response->setBody(json_encode(array("name" => "yaf")));
        // Yaf sends the body after the dispatch loop finishes
    }
}
?>

Прогляньте також

To Top