php8.5
Home/ Manual/ yaf / yaf_action_abstract/ Yaf_Action_Abstract::getController

Yaf_Action_Abstract::getController

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Retrieve controller object

Description

Yaf_Action_Abstract::getController(): Yaf_Controller_Abstract|null

Retrieves the controller that owns this action.

Parameters Parameters

Return Values

A Yaf_Controller_Abstract instance, or null if no controller is available.

Examples

Yaf_Action_Abstract::getController example

php
<?php
class ListAction extends Yaf_Action_Abstract
{
    public function execute() {
        // the controller that owns this action
        $controller = $this->getController();
        var_dump($controller instanceof Yaf_Controller_Abstract);

        // e.g. to reach its view engine
        $controller->getView()->assign("products", array("yaf", "php"));
    }
}
?>

The above example will output something similar to:

output
bool(true)

See Also

  • Yaf_Action_Abstract::getControllerName
  • Yaf_Controller_Abstract

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