Elgg  Version master
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\Application\CacheHandler Class Reference

Simplecache handler. More...

Public Member Functions

 __construct (protected Config $config, protected Request $request, protected SimpleCache $simplecache, ConfigTable $config_table)
 Constructor. More...
 
 handleRequest (Request $request, Application $app)
 Handle a request for a cached view. More...
 
 parsePath ($path)
 Parse a request. More...
 
 getContentType ($view)
 Get the content type. More...
 
 getViewFileType ($view)
 Returns the type of output expected from the view. More...
 

Static Public Attributes

static $extensions
 
static static $utf8_content_types
 

Protected Member Functions

 isCacheableView ($view)
 Is the view cacheable. More...
 
 sendCacheHeaders ($etag, Response $response)
 Sets cache headers. More...
 
 setRevalidateHeaders ($etag, Response $response)
 Set revalidate cache headers. More...
 
 is304 ($etag)
 Send a 304 and exit() if the ETag matches the request. More...
 
 getProcessedView ($view, $viewtype)
 Get the contents of a view for caching. More...
 
 renderView ($view, $viewtype)
 Render a view for caching. More...
 
 send403 ($msg= 'Cache error:bad request')
 Send an error message to requestor. More...
 

Protected Attributes

bool $simplecache_enabled
 

Detailed Description

Simplecache handler.

Definition at line 18 of file CacheHandler.php.

Constructor & Destructor Documentation

Elgg\Application\CacheHandler::__construct ( protected Config  $config,
protected Request  $request,
protected SimpleCache  $simplecache,
ConfigTable  $config_table 
)

Constructor.

Parameters
Config$configElgg configuration
Request$requestHTTP request
SimpleCache$simplecacheSimplecache
ConfigTable$config_tableConfig table

Definition at line 64 of file CacheHandler.php.

Member Function Documentation

Elgg\Application\CacheHandler::getContentType (   $view)

Get the content type.

Parameters
string$viewThe view name
Returns
string|null

Definition at line 293 of file CacheHandler.php.

Elgg\Application\CacheHandler::getProcessedView (   $view,
  $viewtype 
)
protected

Get the contents of a view for caching.

Parameters
string$viewThe view name
string$viewtypeThe viewtype
Returns
string|false
See also
CacheHandler::renderView()

Definition at line 334 of file CacheHandler.php.

Elgg\Application\CacheHandler::getViewFileType (   $view)

Returns the type of output expected from the view.

  • view/name.extension returns "extension" if "extension" is valid
  • css/view return "css"
  • js/view return "js"
  • Otherwise, returns "unknown"
Parameters
string$viewThe view name
Returns
string

Definition at line 311 of file CacheHandler.php.

Elgg\Application\CacheHandler::handleRequest ( Request  $request,
Application  $app 
)

Handle a request for a cached view.

Parameters
Request$requestElgg request
Application$appElgg application
Returns
Response (unprepared)

Definition at line 87 of file CacheHandler.php.

Elgg\Application\CacheHandler::is304 (   $etag)
protected

Send a 304 and exit() if the ETag matches the request.

Parameters
string$etagETag value
Returns
bool

Definition at line 268 of file CacheHandler.php.

Elgg\Application\CacheHandler::isCacheableView (   $view)
protected

Is the view cacheable.

Language views are handled specially.

Parameters
string$viewView name
Returns
bool

Definition at line 225 of file CacheHandler.php.

Elgg\Application\CacheHandler::parsePath (   $path)

Parse a request.

Parameters
string$pathRequest URL path
Returns
array Cache parameters (empty array if failure)

Definition at line 192 of file CacheHandler.php.

Elgg\Application\CacheHandler::renderView (   $view,
  $viewtype 
)
protected

Render a view for caching.

Language views are handled specially.

Parameters
string$viewThe view name
string$viewtypeThe viewtype
Returns
string|false

Definition at line 364 of file CacheHandler.php.

Elgg\Application\CacheHandler::send403 (   $msg = 'Cache error: bad request')
protected

Send an error message to requestor.

Parameters
string$msgOptional message text
Returns
Response

Definition at line 392 of file CacheHandler.php.

Elgg\Application\CacheHandler::sendCacheHeaders (   $etag,
Response  $response 
)
protected

Sets cache headers.

Parameters
string$etagETag value
Response$responsethe response to set the headers on
Returns
void

Definition at line 242 of file CacheHandler.php.

Elgg\Application\CacheHandler::setRevalidateHeaders (   $etag,
Response  $response 
)
protected

Set revalidate cache headers.

Parameters
string$etagETag value
Response$responsethe response to set the headers on
Returns
void

Definition at line 256 of file CacheHandler.php.

Member Data Documentation

Elgg\Application\CacheHandler::$extensions
static
Initial value:
= [
'bmp' => 'image/bmp'

Definition at line 20 of file CacheHandler.php.

bool Elgg\Application\CacheHandler::$simplecache_enabled
protected

Definition at line 54 of file CacheHandler.php.

static Elgg\Application\CacheHandler::$utf8_content_types
static
Initial value:
= [
'text/css',
'text/html',
'text/javascript',
'application/json',
'image/svg+xml',
'text/xml',
]

Definition at line 45 of file CacheHandler.php.


The documentation for this class was generated from the following file: