php8.5
Home/ Manual/ yaf / yaf_controller_abstract/ Yaf_Controller_Abstract::init

Yaf_Controller_Abstract::init

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Controller initializer

Description

Yaf_Controller_Abstract::init(): void

Yaf_Controller_Abstract::__construct is not meant to be overridden with custom logic, so Yaf_Controller_Abstract::init is provided as the userland initialization hook. If it is defined in a controller, it is called right after the controller object is instantiated.

Parameters Parameters

Return Values

No value is returned.

Examples

Yaf_Controller_Abstract::init example

php
<?php
class IndexController extends Yaf_Controller_Abstract
{
    // init() is called right after the controller is instantiated,
    // before any action is dispatched
    public function init() {
        $this->getView()->assign("sitename", "Yaf Tutorial");
    }

    public function indexAction() {
        // ...
    }
}
?>

See Also

  • Yaf_Controller_Abstract::__construct

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