PHP Class Prado\Caching\TDirectoryCacheDependency

TDirectoryCacheDependency performs dependency checking based on the modification time of the files contained in the specified directory. The directory being checked is specified via {@link setDirectory Directory}. By default, all files under the specified directory and subdirectories will be checked. If the last modification time of any of them is changed or if different number of files are contained in a directory, the dependency is reported as changed. By specifying {@link setRecursiveCheck RecursiveCheck} and {@link setRecursiveLevel RecursiveLevel}, one can limit the checking to a certain depth of the subdirectories.
Since: 3.1.0
Author: Qiang Xue ([email protected])
Inheritance: extends TCacheDependency
ファイルを表示 Open project: pradosoft/prado Class Usage Examples

Public Methods

Method Description
__construct ( $directory ) Constructor.
getDirectory ( ) : string
getHasChanged ( ) : boolean Performs the actual dependency checking.
getRecursiveCheck ( ) : boolean
getRecursiveLevel ( ) : integer
setDirectory ( $directory )
setRecursiveCheck ( $value )
setRecursiveLevel ( $value ) Sets a value indicating the depth of the subdirectories to be checked.

Protected Methods

Method Description
generateTimestamps ( $directory, $level ) : array Determines the last modification time for files under the directory.
validateDirectory ( $directory ) : boolean Checks to see if the specified subdirectory should be checked for dependency.
validateFile ( $fileName ) : boolean Checks to see if the file should be checked for dependency.

Method Details

__construct() public method

Constructor.
public __construct ( $directory )

generateTimestamps() protected method

This method may go recursively into subdirectories if {@link setRecursiveCheck RecursiveCheck} is set true.
protected generateTimestamps ( $directory, $level ) : array
return array list of file modification time indexed by the file path

getDirectory() public method

public getDirectory ( ) : string
return string the directory to be checked

getHasChanged() public method

This method returns true if the directory is changed.
public getHasChanged ( ) : boolean
return boolean whether the dependency is changed or not.

getRecursiveCheck() public method

public getRecursiveCheck ( ) : boolean
return boolean whether the subdirectories of the directory will also be checked. It defaults to true.

getRecursiveLevel() public method

public getRecursiveLevel ( ) : integer
return integer the depth of the subdirectories to be checked. It defaults to -1, meaning unlimited depth.

setDirectory() public method

public setDirectory ( $directory )

setRecursiveCheck() public method

public setRecursiveCheck ( $value )

setRecursiveLevel() public method

This is meaningful only when {@link getRecursiveCheck RecursiveCheck} is true.
public setRecursiveLevel ( $value )

validateDirectory() protected method

This method is invoked when dependency of the whole directory is being checked. By default, it always returns true, meaning the subdirectory should be checked. You may override this method to check only certain subdirectories.
protected validateDirectory ( $directory ) : boolean
return boolean whether this subdirectory should be checked.

validateFile() protected method

This method is invoked when dependency of the whole directory is being checked. By default, it always returns true, meaning the file should be checked. You may override this method to check only certain files.
protected validateFile ( $fileName ) : boolean
return boolean whether this file should be checked.