PHP 8.6.0 Beta 3 is available for testing

Yaf_Request_Abstract::setDispatched

(Yaf >=1.0.0)

Yaf_Request_Abstract::setDispatchedMark the request as dispatched

Açıklama

final public function Yaf_Request_Abstract::setDispatched(bool $flag = true): Yaf_Request_Abstract

Mark the request as dispatched

This is called by the dispatcher after an action is executed; it stops the dispatch loop. It can be called manually, e.g. to skip the remaining dispatch iterations.

Bağımsız Değişkenler

flag

The state to set. Defaults to true.

Dönen Değerler

Returns the request object itself.

Örnekler

Örnek 1 Yaf_Request_Abstract::setDispatched() example

<?php
class AuthPlugin extends Yaf_Plugin_Abstract
{
    public function preDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {
        if (empty($_SESSION["user_id"])) {
            // Skip the requested action and redirect to the login page
            $request->setDispatched();
            $response->setRedirect("/account/login");
        }
    }
}
?>

Ayrıca Bakınız

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top