ToolbarPresenter
API reference › Debug › service › ToolbarPresenter
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.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$module protected readonly constructor | yii\ | Debug module read for the toolbar configuration at call time. | ToolbarPresenter |
Methods
Section titled “Methods”| Method | Description | Defined 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() protected | Creates the Yii2-specific toolbar renderer. | ToolbarPresenter |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(yii\debug\Module $module)Binds toolbar presentation to the debug module.
Parameters
| Parameter | Type | Description |
|---|---|---|
$module | yii\ | Debug module read for the toolbar configuration at call time. |
html()
Section titled “html() ”public function html(): stringReturns 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
yii\base\InvalidConfigException: when the module has not been bootstrapped.
injectIntoErrorPage()
Section titled “injectIntoErrorPage() ”public function injectIntoErrorPage(yii\web\ErrorHandlerRenderEvent $event): voidRewrites the rendered HTML of an error page so it carries the toolbar and its runtime script.
Parameters
| Parameter | Type | Description |
|---|---|---|
$event | yii\ | Render event carrying the error-page HTML. |
Throws
yii\base\InvalidConfigException: when the module has not been bootstrapped.
render()
Section titled “render() ”public function render(yii\web\View $view): voidEchoes 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
| Parameter | Type | Description |
|---|---|---|
$view | yii\ | View handling the current response. |
Throws
Throwable: when the view dynamic render fails for the current request.
writeDebugHeaders()
Section titled “writeDebugHeaders() ”public function writeDebugHeaders(yii\web\Response $response): voidSets the tag, duration, and full-view link of the captured request on the response.
Parameters
| Parameter | Type | Description |
|---|---|---|
$response | yii\ | Response about to be sent. |
Throws
yii\base\InvalidConfigException: when the module has not been bootstrapped.
renderer()
Section titled “renderer() ”protected function renderer(yii\base\View|null $view = null): yii\debug\ToolbarRendererCreates 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
| Parameter | Type | Description |
|---|---|---|
$view | yii\| | View handling the current response, or null to use the application view. |
Returns
yii\debug\ToolbarRenderer: Configured toolbar renderer.