Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
eZStaticCache Class Reference
Inheritance diagram for eZStaticCache:

## Public Member Functions
| __construct ()
| hostName ()
| storageDirectory ()
| maxCacheDepth ()
| cachedSiteAccesses ()
| cachedURLArray ()
| alwaysUpdateURLArray ()
| generateAlwaysUpdatedCache ( $quiet=false, $cli=false, $delay=true)
| generateNodeListCache ( $nodeList)
| generateCache ( $force=false, $quiet=false, $cli=false, $delay=true)
| cacheURL ( $url, $nodeID=false, $skipExisting=false, $delay=true)
| removeURL ( $url)

## Static Public Member Functions
static | storeCachedFile ( $file, $content)
static | executeActions ()

## Public Attributes
| $staticStorageDir
const | USER_AGENT = 'eZ Publish static cache generator'

## Private Member Functions
| storeCache ( $url, $staticStorageDir, $alternativeStaticLocations=array(), $skipUnlink=false, $delay=true)
| buildCacheFilename ( $staticStorageDir, $url)
| buildCacheDirPath ( $siteAccess)
| buildCacheDirPart ( $dir, $siteAccess)
| addAction ( $action, $parameters)

## Private Attributes
| $hostName
| $staticStorage
| $maxCacheDepth
| $cachedURLArray = array()
| $cachedSiteAccesses = array()
| $alwaysUpdate

## Static Private Attributes
static | $actionList = array()

## Detailed Description

Definition at line 29 of file ezstaticcache.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZStaticCache::__construct | ( |  | ) |

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

Definition at line 85 of file ezstaticcache.php.

References cachedSiteAccesses(), cachedURLArray(), hostName(), and maxCacheDepth().

## Member Function Documentation

## ◆ addAction()

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 |

Definition at line 569 of file ezstaticcache.php.

Referenced by storeCache().

## ◆ alwaysUpdateURLArray()

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.

Definition at line 155 of file ezstaticcache.php.

References $alwaysUpdate.

## ◆ buildCacheDirPart()

eZStaticCache::buildCacheDirPart | ( |  | $dir,
|  |  | $siteAccess
| ) |  |
| private

A helper method used to create directory parts array

Parameters

  string | $dir |
  string | $siteAccess |

Returns
  array

Definition at line 502 of file ezstaticcache.php.

References eZSiteAccess\getIni().

Referenced by buildCacheDirPath().

## ◆ 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

Definition at line 451 of file ezstaticcache.php.

References buildCacheDirPart().

Referenced by storeCache().

## ◆ buildCacheFilename()

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

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

Parameters

  string | $staticStorageDir | The storage for cache files.
  string | $url | The URL for the current item, e.g /news

Returns
  string The full path to the cache file (index.html).

Definition at line 437 of file ezstaticcache.php.

Referenced by storeCache().

## ◆ cachedSiteAccesses()

eZStaticCache::cachedSiteAccesses | ( |  | ) |

Getter method for eZStaticCache::$cachedSiteAccesses

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

Definition at line 132 of file ezstaticcache.php.

References $cachedSiteAccesses.

Referenced by __construct(), and storeCache().

## ◆ cachedURLArray()

eZStaticCache::cachedURLArray | ( |  | ) |

Getter method for eZStaticCache::$cachedURLArray

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

Definition at line 142 of file ezstaticcache.php.

References $cachedURLArray.

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

## ◆ cacheURL()

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

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

Parameters

  string | $url | The URL to cache, e.g /news
  int | false | $nodeID | The ID of the node to cache, if supplied it will also cache content/view/full/xxx.
  bool | $skipExisting | If true it will not unlink existing cache files.

Returns
  bool

Definition at line 318 of file ezstaticcache.php.

References cachedURLArray(), maxCacheDepth(), and storeCache().

Referenced by generateCache(), and generateNodeListCache().

## ◆ executeActions()

static eZStaticCache::executeActions | ( |  | ) |
| static

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

Definition at line 577 of file ezstaticcache.php.

References eZDB\instance().

## ◆ generateAlwaysUpdatedCache()

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

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

Parameters

  bool | $quiet | If true then the function will not output anything.
  eZCLI | false | $cli | The eZCLI object or false if no output can be done.
  bool | $delay |

Definition at line 167 of file ezstaticcache.php.

References storeCache().

## ◆ generateCache()

eZStaticCache::generateCache | ( |  | $force = `false`,
|  |  | $quiet = `false`,
|  |  | $cli = `false`,
|  |  | $delay = `true`
| ) |  |

Generates the static cache from the configured INI settings.

Parameters

  bool | $force | If true then it will create all static caches even if it is not outdated.
  bool | $quiet | If true then the function will not output anything.
  eZCLI | false | $cli | The eZCLI object or false if no output can be done.
  bool | $delay |

Definition at line 228 of file ezstaticcache.php.

References cachedURLArray(), cacheURL(), eZURLAliasML\fetchByParentID(), eZURLAliasML\fetchByPath(), and eZDB\instance().

## ◆ generateNodeListCache()

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 | $nodeList | An array with node entries, each entry is either the node ID or an associative array.

Definition at line 188 of file ezstaticcache.php.

References cacheURL(), eZURLAliasML\fetchByAction(), eZContentObjectTreeNode\fetchByURLPath(), eZDB\instance(), and eZDebug\writeError().

## ◆ hostName()

eZStaticCache::hostName | ( |  | ) |

Getter method for eZStaticCache::$hostName

Deprecated:
  deprecated since version 4.4

Returns
  string The currently configured host-name.

Definition at line 102 of file ezstaticcache.php.

References $hostName.

Referenced by __construct(), and storeCache().

## ◆ maxCacheDepth()

eZStaticCache::maxCacheDepth | ( |  | ) |

Getter method for eZStaticCache::$maxCacheDepth

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

Definition at line 122 of file ezstaticcache.php.

References $maxCacheDepth.

Referenced by __construct(), and cacheURL().

## ◆ removeURL()

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 | $url | The URL for the current item, e.g /news

Definition at line 554 of file ezstaticcache.php.

References eZDir\path().

## ◆ storageDirectory()

eZStaticCache::storageDirectory | ( |  | ) |

Getter method for eZStaticCache::$staticStorageDir

Returns
  string The currently configured storage directory for the static cache.

Definition at line 112 of file ezstaticcache.php.

References $staticStorageDir.

## ◆ storeCache()

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 | $url | The URL to cache, e.g /news
  string | $staticStorageDir | The base directory for storing cache files.
  array | $alternativeStaticLocations |
  bool | $skipUnlink | If true it will not unlink existing cache files.
  bool | $delay |

Definition at line 362 of file ezstaticcache.php.

References $staticStorageDir, addAction(), buildCacheDirPath(), buildCacheFilename(), cachedSiteAccesses(), eZHTTPTool\getDataByURL(), hostName(), storeCachedFile(), USER_AGENT, and eZDebug\writeError().

Referenced by cacheURL(), and generateAlwaysUpdatedCache().

## ◆ storeCachedFile()

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 |

Definition at line 516 of file ezstaticcache.php.

References eZFile\APPEND_DEBUG_ON_FAILURE, eZFile\CLEAN_ON_FAILURE, eZDir\mkdir(), and eZFile\rename().

Referenced by storeCache().

## Member Data Documentation

## ◆ $actionList

eZStaticCache::$actionList = array()
| static private

Definition at line 37 of file ezstaticcache.php.

## ◆ $alwaysUpdate

eZStaticCache::$alwaysUpdate
| private

Definition at line 80 of file ezstaticcache.php.

Referenced by alwaysUpdateURLArray().

## ◆ $cachedSiteAccesses

eZStaticCache::$cachedSiteAccesses = array()
| private

Definition at line 73 of file ezstaticcache.php.

Referenced by cachedSiteAccesses().

## ◆ $cachedURLArray

eZStaticCache::$cachedURLArray = array()
| private

Definition at line 66 of file ezstaticcache.php.

Referenced by cachedURLArray().

## ◆ $hostName

eZStaticCache::$hostName
| private

Definition at line 45 of file ezstaticcache.php.

Referenced by hostName().

## ◆ $maxCacheDepth

eZStaticCache::$maxCacheDepth
| private

Definition at line 59 of file ezstaticcache.php.

Referenced by maxCacheDepth().

## ◆ $staticStorage

eZStaticCache::$staticStorage
| private

Definition at line 52 of file ezstaticcache.php.

## ◆ $staticStorageDir

eZStaticCache::$staticStorageDir

Definition at line 31 of file ezstaticcache.php.

Referenced by storageDirectory(), and storeCache().

## ◆ USER_AGENT

const eZStaticCache::USER_AGENT = 'eZ Publish static cache generator'

User-Agent string

Definition at line 35 of file ezstaticcache.php.

Referenced by storeCache().

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

- ezstaticcache.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.