KWeb
6.4
|
Base FileDiscovery class, and a registry of instances. More...
Public Member Functions | |
findFile ($name, $searchIn=null, $params=null, $skip=0) | |
Default implementation will return the $name back if it's prefixed with '/' (so that it looks like a full path), and will check for any existing overrides. | |
findAllFiles ($name, $searchIn=null, $params=null, $skip=0) | |
Returns all file paths for specified name. | |
getAllFiles ($regex) | |
Returns all file paths matching the regular expression, or all files if no regex is provided. | |
checkPath ($path) | |
checkPathAndSkip ($path, &$skip) | |
Checks path and handles skip counting. | |
normalizePath ($path) | |
Normalizes path, so it is consistent across function calls. | |
addOverrides (array $overrides) | |
Static Public Member Functions | |
static | instance ($id, $create=true) |
Returns instance of the FileDiscoverer specified by id (e.g. | |
Data Fields | |
const | PARAM_SUBREQUEST = "subrequest" |
This is subrequest. | |
$overrides = array() | |
Array of overrides as [$name] = full path. | |
$id | |
Name of the instance. | |
$useStateCache = true | |
$state = null | |
$stateCacheTimeout = 0 | |
$candidates = null | |
Array of all paths created during findFile. | |
$found = null | |
Array of all existing paths checked during findFile. | |
$iteration = 0 | |
Static Public Attributes | |
static | $stateCacheVersion = '' |
Version indentifier of all files. | |
static | $instances = array() |
Protected Member Functions | |
__construct ($id) | |
prepareStateCache () | |
getFilesState () |
Base FileDiscovery class, and a registry of instances.
FileDiscovery::__construct | ( | $ | id | ) | [protected] |
Reimplemented in FileDiscovery_dirs, KWebFileDiscovery_template, and KWebFileDiscovery_class.
FileDiscovery::addOverrides | ( | array $ | overrides | ) |
FileDiscovery::checkPath | ( | $ | path | ) |
FileDiscovery::checkPathAndSkip | ( | $ | path, |
&$ | skip | ||
) |
Checks path and handles skip counting.
Return true if both path is valid and sufficient number was skipped...
unknown_type | $path | |
unknown_type | $skip |
Returns all file paths for specified name.
Default implementation will return the $name back if it's prefixed with '/' (so that it looks like a full path), and will check for any existing overrides.
During search, most implementations will log candidates and valid paths in $this->candidates and $this->found, but only if these values are initialized to empty arrays beforehand.
To get all the matching files:
$fd->found = array(); $fd->findFile('FooBar', null, null, 0x7fff); var_dump($fd->found); $fd->found = null;
string | $name | |
string | $searchIn | |
array | $params | |
$skip | int|string How many potential entries to skip (both valid and invalid), before matching... You can pass a filepath, to find candidates after this match. |
Implements IFileDiscovery.
Reimplemented in FileDiscovery_dirs, KWebFileDiscovery_template, and KWebFileDiscovery_class.
FileDiscovery::getAllFiles | ( | $ | regex | ) |
Returns all file paths matching the regular expression, or all files if no regex is provided.
May be slow if state cache i disabled! If the discovery doesn't implement prepareStateCache, or getFilesState, than this function won't work...
FileDiscovery::getFilesState | ( | ) | [protected] |
Reimplemented in FileDiscovery_dirs.
static FileDiscovery::instance | ( | $ | id, |
$ | create = true |
||
) | [static] |
Returns instance of the FileDiscoverer specified by id (e.g.
class, image, js and so on)
FileDiscovery::normalizePath | ( | $ | path | ) |
Normalizes path, so it is consistent across function calls.
All paths should be in unix style - without drive letter and with '/' separators.
string | $path |
FileDiscovery::prepareStateCache | ( | ) | [protected] |
FileDiscovery::$candidates = null |
Array of all paths created during findFile.
FileDiscovery::$found = null |
Array of all existing paths checked during findFile.
FileDiscovery::$id |
Name of the instance.
FileDiscovery::$instances = array() [static] |
FileDiscovery::$iteration = 0 |
FileDiscovery::$overrides = array() |
Array of overrides as [$name] = full path.
FileDiscovery::$state = null |
FileDiscovery::$stateCacheTimeout = 0 |
FileDiscovery::$stateCacheVersion = '' [static] |
Version indentifier of all files.
Changing this value will force refresh of the cache
FileDiscovery::$useStateCache = true |
const FileDiscovery::PARAM_SUBREQUEST = "subrequest" |
This is subrequest.
Overrides shouldn't be checked