Elgg\PluginHooksService::registerHandler PHP Метод

registerHandler() публичный Метод

public registerHandler ( $name, $type, $callback, $priority = 500 )
    public function registerHandler($name, $type, $callback, $priority = 500)
    {
        if (($name == 'view' || $name == 'view_vars') && $type !== 'all') {
            $type = _elgg_services()->views->canonicalizeViewName($type);
        }
        return parent::registerHandler($name, $type, $callback, $priority);
    }

Usage Example

Пример #1
0
 /**
  * 1. Register a page handler for `/foo`
  * 2. Register a plugin hook that uses the "handler" result param
  *    to route all `/bar/*` requests to the `/foo` handler.
  * 3. Route a request for a `/bar` page.
  * 4. Check that the `/foo` handler was called.
  */
 function testRouteSupportsSettingHandlerInHookResultForBackwardsCompatibility()
 {
     $this->router->registerPageHandler('foo', array($this, 'foo_page_handler'));
     $this->hooks->registerHandler('route', 'bar', array($this, 'bar_route_handler'));
     $query = http_build_query(array('__elgg_uri' => 'bar/baz'));
     ob_start();
     $this->router->route(\Elgg\Http\Request::create("http://localhost/?{$query}"));
     ob_end_clean();
     $this->assertEquals(1, $this->fooHandlerCalls);
 }
All Usage Examples Of Elgg\PluginHooksService::registerHandler
PluginHooksService