On this page
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.
Property Summary
-
$cacheTime protected
string
The amount of time to cache the asset.
Method Summary
__construct() public
Constructor.
_getAssetFile() protected
Builds asset file path based off url
deliverAsset() protected
Sends an asset file to the client
isNotModified() protected
Check the not modified header.
process() public
Serve assets if the path matches one.
Method Detail
__construct() public
__construct(array<string, mixed> $options = [])
Constructor.
Parameters
array<string, mixed>
$options optional-
The options to use
_getAssetFile() protected
_getAssetFile(string $url): string|null
Builds asset file path based off url
Parameters
string
$url-
Asset URL
Returns
string|null
deliverAsset() protected
deliverAsset(Psr\Http\Message\ServerRequestInterface $request, SplFileInfo $file): Cake\Http\Response
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
isNotModified() protected
isNotModified(Psr\Http\Message\ServerRequestInterface $request, SplFileInfo $file): bool
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(ServerRequestInterface $request, RequestHandlerInterface $handler): Psr\Http\Message\ResponseInterface
Serve assets if the path matches one.
Processes an incoming server request in order to produce a response. If unable to produce the response itself, it may delegate to the provided request handler to do so.
Parameters
ServerRequestInterface
$request-
The request.
RequestHandlerInterface
$handler-
The request handler.
Returns
Psr\Http\Message\ResponseInterface
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.4/class-Cake.Routing.Middleware.AssetMiddleware.html