# AssetLoaderProxy

> Intercepts AssetLoaderInterface::loadBundle() to feed the loaded bundle to the AssetCollector.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Collector](/docs/extensions/yii3-debug/reference/collector/index.md) › AssetLoaderProxy

| final readonly class | `Yii3\Debug\Collector\AssetLoaderProxy` |
| --- | --- |
| Implements | `Yiisoft\Assets\AssetLoaderInterface` |
| Source | [`src/Collector/AssetLoaderProxy.php`](https://github.com/yii3/debug/blob/main/src/Collector/AssetLoaderProxy.php#L12) |

Intercepts `AssetLoaderInterface::loadBundle()` to feed the loaded bundle to the `AssetCollector`.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a transparent asset-loader proxy that records each loaded bundle. | `AssetLoaderProxy` |
| [`getAssetUrl()`](#method-getAssetUrl) | Returns the asset URL the application loader resolves. | `AssetLoaderProxy` |
| [`loadBundle()`](#method-loadBundle) | Records the bundle the application loader resolved, then returns it unchanged. | `AssetLoaderProxy` |

## Method details

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

```php
public function __construct(Yiisoft\Assets\AssetLoaderInterface $loader, Yii3\Debug\Collector\AssetCollector $collector)
```

Creates a transparent asset-loader proxy that records each loaded bundle.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$loader` | `Yiisoft\Assets\AssetLoaderInterface` | Application loader every call is delegated to. |
| `$collector` | [`AssetCollector`](/docs/extensions/yii3-debug/reference/collector/assetcollector/index.md) | Collector recording the bundles the application loads. |

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

```php
public function getAssetUrl(Yiisoft\Assets\AssetBundle $bundle, string $assetPath): string
```

Returns the asset URL the application loader resolves.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$bundle` | `Yiisoft\Assets\AssetBundle` | Bundle the asset file belongs to. |
| `$assetPath` | `string` | Asset path declared by the bundle. |

**Returns**

`string`: Actual URL of the asset.

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

```php
public function loadBundle(string $name, array $config = []): Yiisoft\Assets\AssetBundle
```

Records the bundle the application loader resolved, then returns it unchanged.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string` | Bundle class name to load. |
| `$config` | `array` | Bundle instance configuration. |

**Returns**

`Yiisoft\Assets\AssetBundle`: Bundle as returned by the application loader.