CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • AssetMiddleware
  • RoutingMiddleware

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.

Namespace: Cake\Routing\Middleware
Location: Routing/Middleware/AssetMiddleware.php

Properties summary

  • $cacheTime protected
    string
    The amount of time to cache the asset.
  • $typeMap protected
    array
    A extension to content type mapping for plain text types.

Method Summary

  • __construct() public
    Constructor.
  • __invoke() public
    Serve assets if the path matches one.
  • _getAssetFile() protected
    Builds asset file path based off url
  • deliverAsset() protected
    Sends an asset file to the client
  • getType() protected
    Return the type from a File object
  • isNotModified() protected
    Check 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 )

Serve 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\ResponseInterface
A response

_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 , Psr\Http\Message\ResponseInterface $response , Cake\Filesystem\File $file )

Sends 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\ResponseInterface
The response with the file & headers.

getType() protected ¶

getType( Cake\Filesystem\File $file )

Return the type from a File object

Parameters
Cake\Filesystem\File $file
The file from which you get the type
Returns
string

isNotModified() protected ¶

isNotModified( Psr\Http\Message\ServerRequestInterface $request , Cake\Filesystem\File $file )

Check the not modified header.

Parameters
Psr\Http\Message\ServerRequestInterface $request
The request to check.
Cake\Filesystem\File $file
The file object to compare.
Returns
boolean

Properties detail

$cacheTime ¶

protected string

The amount of time to cache the asset.

'+1 day'

$typeMap ¶

protected array

A extension to content type mapping for plain text types.

Because finfo doesn't give useful information for plain text types, we have to handle that here.

[
    'css' => 'text/css',
    'json' => 'application/json',
    'js' => 'application/javascript',
    'ico' => 'image/x-icon',
    'eot' => 'application/vnd.ms-fontobject',
    'svg' => 'image/svg+xml',
    'html' => 'text/html',
    'rss' => 'application/rss+xml',
    'xml' => 'application/xml',
]
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs