Class AssetMiddleware

Handles serving plugin assets in development mode.

This should not be used in production environments as it has sub-optimal performance when compared to serving files with a real webserver.

Properties summary

  • $cacheTime protected
    string

    The amount of time to cache the asset.

Method Summary

Method Detail

__construct() public

__construct(array $options)

Constructor.

Parameters

array $options optional

The options to use

_getAssetFile() protected

_getAssetFile(string $url)

Builds asset file path based off url

Parameters

string $url

Asset URL

Returns

string|null

Absolute path for asset file, null on failure

deliverAsset() protected

deliverAsset(\Psr\Http\Message\ServerRequestInterface $request, \SplFileInfo $file)

Sends an asset file to the client

Parameters

\Psr\Http\Message\ServerRequestInterface $request

The request object to use.

\SplFileInfo $file

The file wrapper for the file.

Returns

\Cake\Http\Response

The response with the file & headers.

isNotModified() protected

isNotModified(\Psr\Http\Message\ServerRequestInterface $request, \SplFileInfo $file)

Check the not modified header.

Parameters

\Psr\Http\Message\ServerRequestInterface $request

The request to check.

\SplFileInfo $file

The file object to compare.

Returns

bool

process() public

process(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler)

Serve assets if the path matches one.

Parameters

\Psr\Http\Message\ServerRequestInterface $request

The request.

\Psr\Http\Server\RequestHandlerInterface $handler

The request handler.

Returns

\Psr\Http\Message\ResponseInterface

A response.

Property Detail

$cacheTime protected

The amount of time to cache the asset.

Type

string

© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.0/class-Cake.Routing.Middleware.AssetMiddleware.html