php8.5
Home/ Manual/ yaf / yaf_dispatcher/ Yaf_Dispatcher::enableView

Yaf_Dispatcher::enableView

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Enable view rendering

Description

Yaf_Dispatcher::enableView(): Yaf_Dispatcher|null

Turn on view rendering. This is the opposite of Yaf_Dispatcher::disableView.

Parameters Parameters

Return Values

Returns the Yaf_Dispatcher object itself on success, or null if the application is not initialized.

Examples

Yaf_Dispatcher::enableView example

php
<?php
class ApiPlugin extends Yaf_Plugin_Abstract
{
    public function routerStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {
        $dispatcher = Yaf_Dispatcher::getInstance();

        if ($request->getModuleName() === "Api") {
            // API actions emit JSON themselves, no view rendering wanted
            $dispatcher->disableView();
        } else {
            $dispatcher->enableView();
        }
    }
}
?>

See Also

  • Yaf_Dispatcher::disableView
  • Yaf_Dispatcher::autoRender

Source: reference/yaf/yaf_dispatcher/enableview.xml · from the official PHP manual (php/doc-en)