HTMLPurifier_DefinitionCache_Serializer
extends HTMLPurifier_DefinitionCache
in package
Abstract class representing Definition cache managers that implements useful common methods and is a factory.
Table of Contents
Properties
- $type : mixed
Methods
- __construct() : mixed
- add() : int|bool
- Adds a definition object to the cache
- checkDefType() : bool
- Checks if a definition's type jives with the cache's type
- cleanup() : bool
- Clears all expired (older version or revision) objects from cache
- flush() : bool
- Clears all objects from cache
- generateBaseDirectoryPath() : mixed|string
- Generates path to base directory that contains all definition type serials
- generateDirectoryPath() : string
- Generates the path to the directory contain this cache's serial files
- generateFilePath() : string
- Generates the file path to the serial file corresponding to the configuration and definition name
- generateKey() : string
- Generates a unique identifier for a particular configuration
- get() : bool|HTMLPurifier_Config
- Retrieves a definition object from the cache
- isOld() : bool
- Tests whether or not a key is old with respect to the configuration's version and revision number.
- remove() : bool
- Removes a definition object to the cache
- replace() : int|bool
- Replace an object in the cache
- set() : int|bool
- Unconditionally saves a definition object to the cache
- _prepareDir() : bool
- Prepares the directory that this type stores the serials in
- _testPermissions() : bool
- Tests permissions on a directory and throws out friendly error messages and attempts to chmod it itself if possible
- _write() : int|bool
- Convenience wrapper function for file_put_contents
Properties
$type
public
mixed
$type
Tags
Methods
__construct()
public
__construct(string $type) : mixed
Parameters
- $type : string
-
Type of definition objects this instance of the cache will handle.
add()
Adds a definition object to the cache
public
add(HTMLPurifier_Definition $def, HTMLPurifier_Config $config) : int|bool
Parameters
- $def : HTMLPurifier_Definition
- $config : HTMLPurifier_Config
Return values
int|boolcheckDefType()
Checks if a definition's type jives with the cache's type
public
checkDefType(HTMLPurifier_Definition $def) : bool
Parameters
- $def : HTMLPurifier_Definition
-
Definition object to check
Tags
Return values
bool —true if good, false if not
cleanup()
Clears all expired (older version or revision) objects from cache
public
cleanup(HTMLPurifier_Config $config) : bool
Parameters
- $config : HTMLPurifier_Config
Return values
boolflush()
Clears all objects from cache
public
flush(HTMLPurifier_Config $config) : bool
Parameters
- $config : HTMLPurifier_Config
Return values
boolgenerateBaseDirectoryPath()
Generates path to base directory that contains all definition type serials
public
generateBaseDirectoryPath(HTMLPurifier_Config $config) : mixed|string
Parameters
- $config : HTMLPurifier_Config
Tags
Return values
mixed|stringgenerateDirectoryPath()
Generates the path to the directory contain this cache's serial files
public
generateDirectoryPath(HTMLPurifier_Config $config) : string
Parameters
- $config : HTMLPurifier_Config
Tags
Return values
stringgenerateFilePath()
Generates the file path to the serial file corresponding to the configuration and definition name
public
generateFilePath(HTMLPurifier_Config $config) : string
Parameters
- $config : HTMLPurifier_Config
Tags
Return values
stringgenerateKey()
Generates a unique identifier for a particular configuration
public
generateKey(HTMLPurifier_Config $config) : string
Parameters
- $config : HTMLPurifier_Config
-
Instance of HTMLPurifier_Config
Return values
stringget()
Retrieves a definition object from the cache
public
get(HTMLPurifier_Config $config) : bool|HTMLPurifier_Config
Parameters
- $config : HTMLPurifier_Config
Return values
bool|HTMLPurifier_ConfigisOld()
Tests whether or not a key is old with respect to the configuration's version and revision number.
public
isOld(string $key, HTMLPurifier_Config $config) : bool
Parameters
- $key : string
-
Key to test
- $config : HTMLPurifier_Config
-
Instance of HTMLPurifier_Config to test against
Return values
boolremove()
Removes a definition object to the cache
public
remove(HTMLPurifier_Config $config) : bool
Parameters
- $config : HTMLPurifier_Config
Return values
boolreplace()
Replace an object in the cache
public
replace(HTMLPurifier_Definition $def, HTMLPurifier_Config $config) : int|bool
Parameters
- $def : HTMLPurifier_Definition
- $config : HTMLPurifier_Config
Return values
int|boolset()
Unconditionally saves a definition object to the cache
public
set(HTMLPurifier_Definition $def, HTMLPurifier_Config $config) : int|bool
Parameters
- $def : HTMLPurifier_Definition
- $config : HTMLPurifier_Config
Return values
int|bool_prepareDir()
Prepares the directory that this type stores the serials in
private
_prepareDir(HTMLPurifier_Config $config) : bool
Parameters
- $config : HTMLPurifier_Config
Return values
bool —True if successful
_testPermissions()
Tests permissions on a directory and throws out friendly error messages and attempts to chmod it itself if possible
private
_testPermissions(string $dir, int $chmod) : bool
Parameters
- $dir : string
-
Directory path
- $chmod : int
-
Permissions
Return values
bool —True if directory is writable
_write()
Convenience wrapper function for file_put_contents
private
_write(string $file, string $data, HTMLPurifier_Config $config) : int|bool
Parameters
- $file : string
-
File name to write to
- $data : string
-
Data to write into file
- $config : HTMLPurifier_Config
Return values
int|bool —Number of bytes written if success, or false if failure.