Skip to content
PHP Ecosystem
Explore

ToolbarPresenter

API reference › Debug › service › ToolbarPresenter

classyii\debug\service\ToolbarPresenter
Sourcesrc/service/ToolbarPresenter.php

Renders the debug toolbar into a page and reports the captured request through the debug response headers.

The caller decides whether the current request may see the toolbar; every method here assumes that decision was already made.

PropertyTypeDescriptionDefined by
$module protected readonly constructoryii\debug\ModuleDebug module read for the toolbar configuration at call time.ToolbarPresenter
MethodDescriptionDefined by
__construct()Binds toolbar presentation to the debug module.ToolbarPresenter
html()Returns the toolbar HTML: a <yii-debug-toolbar> custom element wired with data attributes the bundled JS reads.ToolbarPresenter
injectIntoErrorPage()Rewrites the rendered HTML of an error page so it carries the toolbar and its runtime script.ToolbarPresenter
render()Echoes the toolbar and its runtime script at the end of the page body.ToolbarPresenter
writeDebugHeaders()Sets the tag, duration, and full-view link of the captured request on the response.ToolbarPresenter
renderer() protectedCreates the Yii2-specific toolbar renderer.ToolbarPresenter
public function __construct(yii\debug\Module $module)

Binds toolbar presentation to the debug module.

Parameters

ParameterTypeDescription
$moduleyii\debug\ModuleDebug module read for the toolbar configuration at call time.
public function html(): string

Returns the toolbar HTML: a <yii-debug-toolbar> custom element wired with data attributes the bundled JS reads.

Returns

string: Rendered <yii-debug-toolbar> element.

Throws

public function injectIntoErrorPage(yii\web\ErrorHandlerRenderEvent $event): void

Rewrites the rendered HTML of an error page so it carries the toolbar and its runtime script.

Parameters

ParameterTypeDescription
$eventyii\web\ErrorHandlerRenderEventRender event carrying the error-page HTML.

Throws

public function render(yii\web\View $view): void

Echoes the toolbar and its runtime script at the end of the page body.

The toolbar markup is rendered dynamically, so a cached page still carries the tag of the request that served it, while the runtime URL is resolved through the Yii2 asset manager.

Parameters

ParameterTypeDescription
$viewyii\web\ViewView handling the current response.

Throws

  • Throwable: when the view dynamic render fails for the current request.
public function writeDebugHeaders(yii\web\Response $response): void

Sets the tag, duration, and full-view link of the captured request on the response.

Parameters

ParameterTypeDescription
$responseyii\web\ResponseResponse about to be sent.

Throws

protected function renderer(yii\base\View|null $view = null): yii\debug\ToolbarRenderer

Creates the Yii2-specific toolbar renderer.

Override point: a subclass returning its own renderer changes the templates and the asset publisher every method here draws the toolbar markup and its runtime script from.

Parameters

ParameterTypeDescription
$viewyii\base\View|nullView handling the current response, or null to use the application view.

Returns

yii\debug\ToolbarRenderer: Configured toolbar renderer.