# ToolbarDataAction

> Serves the toolbar payload for a captured request.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Action](/docs/extensions/yii3-debug/reference/action/index.md) › ToolbarDataAction

| final readonly class | `Yii3\Debug\Action\ToolbarDataAction` |
| --- | --- |
| Implements | [`DebugActionInterface`](/docs/extensions/yii3-debug/reference/action/debugactioninterface/index.md) |
| Source | [`src/Action/ToolbarDataAction.php`](https://github.com/yii3/debug/blob/main/src/Action/ToolbarDataAction.php#L23) |

Serves the toolbar payload for a captured request.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates the toolbar-data endpoint, optionally backed by retained captures. | `ToolbarDataAction` |
| [`__invoke()`](#method-__invoke) | Serves the toolbar payload for the capture the query parameters select. | `ToolbarDataAction` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(Yii3\Debug\ToolbarDataFactory $dataFactory, Psr\Http\Message\ResponseFactoryInterface $responseFactory, Psr\Http\Message\StreamFactoryInterface $streamFactory, PHPForge\Debug\Storage\SnapshotStore|null $store = null)
```

Creates the toolbar-data endpoint, optionally backed by retained captures.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$dataFactory` | [`Yii3\Debug\ToolbarDataFactory`](/docs/extensions/yii3-debug/reference/toolbardatafactory/index.md) | Factory building the toolbar payload. |
| `$responseFactory` | `Psr\Http\Message\ResponseFactoryInterface` | Factory building the PSR-7 response. |
| `$streamFactory` | `Psr\Http\Message\StreamFactoryInterface` | Factory building the PSR-7 response body. |
| `$store` | `PHPForge\Debug\Storage\SnapshotStore\|null` | Store the capture is read from, or `null` when none is configured. |

### __invoke() <span id="method-__invoke"></span>

```php
public function __invoke(Psr\Http\Message\ServerRequestInterface $request): Psr\Http\Message\ResponseInterface
```

Serves the toolbar payload for the capture the query parameters select.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$request` | `Psr\Http\Message\ServerRequestInterface` | Incoming request carrying the query parameters. |

**Returns**

`Psr\Http\Message\ResponseInterface`: JSON toolbar payload, or an error response when the capture is missing.

**Throws**

- [`JsonException`](https://www.php.net/manual/en/class.jsonexception.php): when the toolbar payload cannot be encoded.