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 protectedstringThe amount of time to cache the asset. 
- 
        $typeMap protectedarrayA extension to content type mapping for plain text types. 
Method Summary
- 
          __construct() publicConstructor. 
- 
          __invoke() publicServe assets if the path matches one. 
- 
          _getAssetFile() protectedBuilds asset file path based off url 
- 
          deliverAsset() protectedSends an asset file to the client 
- 
          getType() protectedReturn the type from a File object 
- 
          isNotModified() protectedCheck the not modified header. 
Method Detail
__construct() ¶ public
__construct(array $options = [])Constructor.
Parameters
- 
                array$options optional
- The options to use 
__invoke() ¶ public
__invoke(Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next): Psr\Http\Message\ResponseInterfaceServe assets if the path matches one.
Parameters
- 
                Psr\Http\Message\ServerRequestInterface$request
- The request. 
- 
                Psr\Http\Message\ResponseInterface$response
- The response. 
- 
                callable$next
- Callback to invoke the next middleware. 
Returns
Psr\Http\Message\ResponseInterfaceA response
_getAssetFile() ¶ protected
_getAssetFile(string $url): stringBuilds asset file path based off url
Parameters
- 
                string$url
- Asset URL 
Returns
stringAbsolute path for asset file
deliverAsset() ¶ protected
deliverAsset(Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, Cake\Filesystem\File $file): Psr\Http\Message\ResponseInterfaceSends an asset file to the client
Parameters
- 
                Psr\Http\Message\ServerRequestInterface$request
- The request object to use. 
- 
                Psr\Http\Message\ResponseInterface$response
- The response object to use. 
- 
                Cake\Filesystem\File$file
- The file wrapper for the file. 
Returns
Psr\Http\Message\ResponseInterfaceThe response with the file & headers.
getType() ¶ protected
getType(File $file): stringReturn the type from a File object
Parameters
- 
                File$file
- The file from which you get the type 
Returns
stringisNotModified() ¶ protected
isNotModified(Psr\Http\Message\ServerRequestInterface $request, Cake\Filesystem\File $file): boolCheck the not modified header.
Parameters
- 
                Psr\Http\Message\ServerRequestInterface$request
- The request to check. 
- 
                Cake\Filesystem\File$file
- The file object to compare. 
Returns
bool