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

Yaf_Dispatcher::registerPlugin

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Register a plugin

Description

Yaf_Dispatcher::registerPlugin(Yaf_Plugin_Abstract $plugin): Yaf_Dispatcher|null|false

Register a plugin (see Yaf_Plugin_Abstract). Generally, plugins are registered in Bootstrap (see Yaf_Bootstrap_Abstract).

Parameters

plugin

A Yaf_Plugin_Abstract instance.

Return Values

Returns the Yaf_Dispatcher object itself on success, or false / null on failure.

Examples

Yaf_Dispatcher::registerPlugin() example

php
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
  public function _initPlugin(Yaf_Dispatcher $dispatcher) {
    /**
    * Yaf assumes plugin scripts under [application.directory] .  "/plugins" 
    * for this case, it will be:
    * [application.directory] . "/plugins/" . "User" . [application.ext]
    */ 
    $user = new UserPlugin();
    $dispatcher->registerPlugin($user);
  }
}
?>

See Also

  • Yaf_Plugin_Abstract
  • Yaf_Bootstrap_Abstract

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