\HTMLPurifier_DefinitionCache_Serializer

Abstract class representing Definition cache managers that implements useful common methods and is a factory.

Summary

Methods
Properties
Constants
__construct()
generateKey()
isOld()
checkDefType()
add()
set()
replace()
get()
remove()
flush()
cleanup()
generateFilePath()
generateDirectoryPath()
generateBaseDirectoryPath()
$type
No constants found
No protected methods found
No protected properties found
N/A
_write()
_prepareDir()
_testPermissions()
No private properties found
N/A

Properties

$type

$type

Methods

__construct()

__construct(string  $type) : mixed

Parameters

string $type

Type of definition objects this instance of the cache will handle.

Returns

mixed —

generateKey()

generateKey(\HTMLPurifier_Config  $config) : string

Generates a unique identifier for a particular configuration

Parameters

\HTMLPurifier_Config $config

Instance of HTMLPurifier_Config

Returns

string —

isOld()

isOld(string  $key, \HTMLPurifier_Config  $config) : bool

Tests whether or not a key is old with respect to the configuration's version and revision number.

Parameters

string $key

Key to test

\HTMLPurifier_Config $config

Instance of HTMLPurifier_Config to test against

Returns

bool —

checkDefType()

checkDefType(\HTMLPurifier_Definition  $def) : bool

Checks if a definition's type jives with the cache's type

Parameters

\HTMLPurifier_Definition $def

Definition object to check

Returns

bool —

true if good, false if not

add()

add(\HTMLPurifier_Definition  $def, \HTMLPurifier_Config  $config) : int|bool

Adds a definition object to the cache

Parameters

\HTMLPurifier_Definition $def
\HTMLPurifier_Config $config

Returns

int|bool —

set()

set(\HTMLPurifier_Definition  $def, \HTMLPurifier_Config  $config) : int|bool

Unconditionally saves a definition object to the cache

Parameters

\HTMLPurifier_Definition $def
\HTMLPurifier_Config $config

Returns

int|bool —

replace()

replace(\HTMLPurifier_Definition  $def, \HTMLPurifier_Config  $config) : int|bool

Replace an object in the cache

Parameters

\HTMLPurifier_Definition $def
\HTMLPurifier_Config $config

Returns

int|bool —

get()

get(\HTMLPurifier_Config  $config) : bool|\HTMLPurifier_Config

Retrieves a definition object from the cache

Parameters

\HTMLPurifier_Config $config

Returns

bool|\HTMLPurifier_Config —

remove()

remove(\HTMLPurifier_Config  $config) : bool

Removes a definition object to the cache

Parameters

\HTMLPurifier_Config $config

Returns

bool —

flush()

flush(\HTMLPurifier_Config  $config) : bool

Clears all objects from cache

Parameters

\HTMLPurifier_Config $config

Returns

bool —

cleanup()

cleanup(\HTMLPurifier_Config  $config) : bool

Clears all expired (older version or revision) objects from cache

Parameters

\HTMLPurifier_Config $config

Returns

bool —

generateFilePath()

generateFilePath(\HTMLPurifier_Config  $config) : string

Generates the file path to the serial file corresponding to the configuration and definition name

Parameters

\HTMLPurifier_Config $config

Returns

string —

generateDirectoryPath()

generateDirectoryPath(\HTMLPurifier_Config  $config) : string

Generates the path to the directory contain this cache's serial files

Parameters

\HTMLPurifier_Config $config

Returns

string —

generateBaseDirectoryPath()

generateBaseDirectoryPath(\HTMLPurifier_Config  $config) : mixed|string

Generates path to base directory that contains all definition type serials

Parameters

\HTMLPurifier_Config $config

Returns

mixed|string —

_write()

_write(string  $file, string  $data, \HTMLPurifier_Config  $config) : int|bool

Convenience wrapper function for file_put_contents

Parameters

string $file

File name to write to

string $data

Data to write into file

\HTMLPurifier_Config $config

Returns

int|bool —

Number of bytes written if success, or false if failure.

_prepareDir()

_prepareDir(\HTMLPurifier_Config  $config) : bool

Prepares the directory that this type stores the serials in

Parameters

\HTMLPurifier_Config $config

Returns

bool —

True if successful

_testPermissions()

_testPermissions(string  $dir, int  $chmod) : bool

Tests permissions on a directory and throws out friendly error messages and attempts to chmod it itself if possible

Parameters

string $dir

Directory path

int $chmod

Permissions

Returns

bool —

True if directory is writable