eZPublish  4.4
eZStaticCache Class Reference

Public Member Functions

 __construct ()
 Initialises the static cache object with settings from staticcache.ini. More...
 
 alwaysUpdateURLArray ()
 Getter method for eZStaticCache::$alwaysUpdate. More...
 
 cachedSiteAccesses ()
 Getter method for eZStaticCache::$cachedSiteAccesses. More...
 
 cachedURLArray ()
 Getter method for eZStaticCache::$cachedURLArray. More...
 
 cacheURL ($url, $nodeID=false, $skipExisting=false, $delay=true)
 Generates the caches for the url $url using the currently configured storageDirectory(). More...
 
 generateAlwaysUpdatedCache ($quiet=false, $cli=false, $delay=true)
 Generates the caches for all URLs that must always be generated. More...
 
 generateCache ($force=false, $quiet=false, $cli=false, $delay=true)
 Generates the static cache from the configured INI settings. More...
 
 generateNodeListCache ($nodeList)
 Generates caches for all the urls of nodes in $nodeList. More...
 
 hostName ()
 Getter method for eZStaticCache::$hostName. More...
 
 maxCacheDepth ()
 Getter method for eZStaticCache::$maxCacheDepth. More...
 
 removeURL ($url)
 Removes the static cache file (index.html) and its directory if it exists. More...
 
 storageDirectory ()
 Getter method for eZStaticCache::$staticStorageDir. More...
 

Static Public Member Functions

static executeActions ()
 This function goes over the list of recorded actions and excecutes them. More...
 
static storeCachedFile ($file, $content)
 Stores the cache file $file with contents $content. More...
 

Public Attributes

const USER_AGENT = 'eZ Publish static cache generator'
 User-Agent string. More...
 

Private Member Functions

 addAction ($action, $parameters)
 This function adds an action to the list that is used at the end of the request to remove and regenerate static cache files. More...
 
 buildCacheDirPart ($dir, $siteAccess)
 A helper method used to create directory parts array. More...
 
 buildCacheDirPath ($siteAccess)
 Generates a cache directory parts including path, siteaccess name, site URL depending on the match order type. More...
 
 buildCacheFilename ($staticStorageDir, $url)
 Generates a full path to the cache file (index.html) based on the input parameters. More...
 
 storeCache ($url, $staticStorageDir, $alternativeStaticLocations=array(), $skipUnlink=false, $delay=true)
 Stores the static cache for $url and hostname defined in site.ini. More...
 

Private Attributes

 $alwaysUpdate
 
 $cachedSiteAccesses = array()
 
 $cachedURLArray = array()
 
 $hostName
 
 $maxCacheDepth
 
 $staticStorage
 

Constructor & Destructor Documentation

eZStaticCache::__construct ( )

Initialises the static cache object with settings from staticcache.ini.

Member Function Documentation

eZStaticCache::addAction (   $action,
  $parameters 
)
private

This function adds an action to the list that is used at the end of the request to remove and regenerate static cache files.

Parameters
string$action
array$parameters

Referenced by storeCache().

eZStaticCache::alwaysUpdateURLArray ( )

Getter method for eZStaticCache::$alwaysUpdate.

These URLs are configured with AlwaysUpdateArray in staticcache.ini.

See Also
eZStaticCache::generateAlwaysUpdatedCache()
Returns
array An array with URLs that is to always be updated.
eZStaticCache::buildCacheDirPart (   $dir,
  $siteAccess 
)
private

A helper method used to create directory parts array.

Parameters
string$dir
string$siteAccess
Returns
array

Referenced by buildCacheDirPath().

eZStaticCache::buildCacheDirPath (   $siteAccess)
private

Generates a cache directory parts including path, siteaccess name, site URL depending on the match order type.

Parameters
string$siteAccess
Returns
array

Referenced by storeCache().

eZStaticCache::buildCacheFilename (   $staticStorageDir,
  $url 
)
private

Generates a full path to the cache file (index.html) based on the input parameters.

Parameters
string$staticStorageDirThe storage for cache files.
string$urlThe URL for the current item, e.g /news
Returns
string The full path to the cache file (index.html).

Referenced by storeCache().

eZStaticCache::cachedSiteAccesses ( )

Getter method for eZStaticCache::$cachedSiteAccesses.

Returns
array An array with site-access names that should be cached.

Referenced by __construct(), and storeCache().

eZStaticCache::cachedURLArray ( )

Getter method for eZStaticCache::$cachedURLArray.

Returns
array An array with URLs that is to be cached statically, the URLs may contain wildcards.

Referenced by __construct(), cacheURL(), and generateCache().

eZStaticCache::cacheURL (   $url,
  $nodeID = false,
  $skipExisting = false,
  $delay = true 
)

Generates the caches for the url $url using the currently configured storageDirectory().

Parameters
string$urlThe URL to cache, e.g /news
int | false$nodeIDThe ID of the node to cache, if supplied it will also cache content/view/full/xxx.
bool$skipExistingIf true it will not unlink existing cache files.
Returns
bool

Referenced by generateCache(), and generateNodeListCache().

static eZStaticCache::executeActions ( )
static

This function goes over the list of recorded actions and excecutes them.

eZStaticCache::generateAlwaysUpdatedCache (   $quiet = false,
  $cli = false,
  $delay = true 
)

Generates the caches for all URLs that must always be generated.

Parameters
bool$quietIf true then the function will not output anything.
eZCLI | false$cliThe eZCLI object or false if no output can be done.
bool$delay
eZStaticCache::generateCache (   $force = false,
  $quiet = false,
  $cli = false,
  $delay = true 
)

Generates the static cache from the configured INI settings.

Parameters
bool$forceIf true then it will create all static caches even if it is not outdated.
bool$quietIf true then the function will not output anything.
eZCLI | false$cliThe eZCLI object or false if no output can be done.
bool$delay
eZStaticCache::generateNodeListCache (   $nodeList)

Generates caches for all the urls of nodes in $nodeList.

The associative array must have on of these entries:

  • node_id - ID of the node
  • path_identification_string - The path_identification_string from the node table, is used to fetch the node ID if node_id is missing.
Parameters
array$nodeListAn array with node entries, each entry is either the node ID or an associative array.
eZStaticCache::hostName ( )

Getter method for eZStaticCache::$hostName.

Deprecated:
deprecated since version 4.4
Returns
string The currently configured host-name.

Referenced by __construct(), and storeCache().

eZStaticCache::maxCacheDepth ( )

Getter method for eZStaticCache::$maxCacheDepth.

Returns
int The maximum depth in the url which will be cached.

Referenced by __construct(), and cacheURL().

eZStaticCache::removeURL (   $url)

Removes the static cache file (index.html) and its directory if it exists.

The directory path is based upon the URL $url and the configured static storage dir.

Parameters
string$urlThe URL for the current item, e.g /news
eZStaticCache::storageDirectory ( )

Getter method for eZStaticCache::$staticStorageDir.

Returns
string The currently configured storage directory for the static cache.
eZStaticCache::storeCache (   $url,
  $staticStorageDir,
  $alternativeStaticLocations = array(),
  $skipUnlink = false,
  $delay = true 
)
private

Stores the static cache for $url and hostname defined in site.ini.

[SiteSettings].SiteURL for cached siteaccess by fetching the web page using eZHTTPTool::getDataByURL() and storing the fetched HTML data.

Parameters
string$urlThe URL to cache, e.g /news
string$staticStorageDirThe base directory for storing cache files.
array$alternativeStaticLocations
bool$skipUnlinkIf true it will not unlink existing cache files.
bool$delay

Referenced by cacheURL(), and generateAlwaysUpdatedCache().

static eZStaticCache::storeCachedFile (   $file,
  $content 
)
static

Stores the cache file $file with contents $content.

Takes care of setting proper permissions on the new file.

Parameters
string$file
string$content

Referenced by storeCache().

Member Data Documentation

eZStaticCache::$alwaysUpdate
private

Referenced by alwaysUpdateURLArray().

eZStaticCache::$cachedSiteAccesses = array()
private

Referenced by cachedSiteAccesses().

eZStaticCache::$cachedURLArray = array()
private

Referenced by cachedURLArray().

eZStaticCache::$hostName
private

Referenced by hostName().

eZStaticCache::$maxCacheDepth
private

Referenced by maxCacheDepth().

eZStaticCache::$staticStorage
private
const eZStaticCache::USER_AGENT = 'eZ Publish static cache generator'

User-Agent string.

Referenced by storeCache().


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