Allows to easily find files residing inside rapila’s site structure, following the precedence rules (site > plugins > base).
More...
|
| __construct ($aPath=array(), $iFlag=null) |
|
| byExpressions ($bByExpressions=true) |
|
| all ($bFindAll=true) |
|
| returnObjects ($bReturnObjects=true) |
|
| noCache ($bNoCache=true) |
|
| mainOnly () |
|
| baseOnly () |
|
| siteOnly () |
|
| pluginsOnly () |
|
| baseFirst () |
|
| siteFirst () |
|
| pluginsFirst () |
|
| searchMainOnly () |
|
| searchBaseOnly () |
|
| searchSiteOnly () |
|
| searchPluginsOnly () |
|
| searchBaseFirst () |
|
| searchSiteFirst () |
|
| searchPluginsFirst () |
|
| resultIsArray () |
|
| resultIsAssoc () |
|
| returnsObjects () |
|
| addPath () |
|
| addExpression () |
|
| addOptionalPath () |
|
| addRecursion () |
|
| addAnyPath ($bOptional=false) |
|
| addDirPath ($bOptional=false) |
|
| addFilePath ($bOptional=false) |
|
| addSame ($bCamelized=false) |
|
| find () |
|
|
static | create ($aPath=array(), $iFlag=null) |
|
static | findResource ($mRelativePath, $iFlag=null, $bByExpressions=false, $bFindAll=false, $bReturnObjects=false) |
|
static | findAllResources ($mRelativePath, $iFlag=null) |
|
static | findResourceByExpressions ($aExpressions, $iFlag=null) |
|
static | findResourcesByExpressions ($aExpressions, $iFlag=null) |
|
static | findAllResourcesByExpressions ($aExpressions, $iFlag=null) |
|
static | findResourceObject ($mRelativePath, $iFlag=null) |
|
static | findAllResourceObjects ($mRelativePath, $iFlag=null) |
|
static | findResourceObjectByExpressions ($aExpressions, $iFlag=null) |
|
static | findResourceObjectsByExpressions ($aExpressions, $iFlag=null) |
|
static | findAllResourceObjectsByExpressions ($aExpressions, $iFlag=null) |
|
static | pluginFinder () |
|
static | parsePathArguments ($sBaseDirname=null, $mPath=null, $sFileName=null) |
|
static | getFolderContents ($sPath, $bIncludeInvisibles=false) |
|
static | mimeTypeOfFile ($sFile) |
|
static | recursiveUnlink ($sFileName) |
|
|
const | SEARCH_MAIN_ONLY = 0 |
|
const | SEARCH_BASE_ONLY = 1 |
|
const | SEARCH_SITE_ONLY = 2 |
|
const | SEARCH_PLUGINS_ONLY = 5 |
|
const | SEARCH_BASE_FIRST = 3 |
|
const | SEARCH_SITE_FIRST = 4 |
|
const | SEARCH_PLUGINS_FIRST = 6 |
|
const | WILDCARD_ANY = null |
|
const | WILDCARD_DIR = false |
|
const | WILDCARD_FILE = true |
|
const | ANY_NAME_OR_TYPE_PATTERN = '/^[\\w_]+$/' |
|
Allows to easily find files residing inside rapila’s site structure, following the precedence rules (site > plugins > base).
ResourceFinder::addSame |
( |
|
$bCamelized = false | ) |
|
Adds a resource that needs to have the same name as the parent folder.
- Parameters
-
$bCamelized | will camelize the parent name before matching. |
- Returns
- bool|string|FileResource|array the matched path(s)
static ResourceFinder::findAllResourceObjects |
( |
|
$mRelativePath, |
|
|
|
$iFlag = null |
|
) |
| |
|
static |
static ResourceFinder::findAllResourceObjectsByExpressions |
( |
|
$aExpressions, |
|
|
|
$iFlag = null |
|
) |
| |
|
static |
static ResourceFinder::findAllResources |
( |
|
$mRelativePath, |
|
|
|
$iFlag = null |
|
) |
| |
|
static |
static ResourceFinder::findAllResourcesByExpressions |
( |
|
$aExpressions, |
|
|
|
$iFlag = null |
|
) |
| |
|
static |
static ResourceFinder::findResource |
( |
|
$mRelativePath, |
|
|
|
$iFlag = null , |
|
|
|
$bByExpressions = false , |
|
|
|
$bFindAll = false , |
|
|
|
$bReturnObjects = false |
|
) |
| |
|
static |
Finds files which reside inside the CMS’ main direcory. The goal of findResource is to provide a way of accessing all the desired resources from the most specific location. Files in the site folder override files in the plugins folders which, in turn, override files in the base folder. The return type varies depending on the given options ($bByExpressions, $bFindAll, $bReturnObjects). If $bReturnObjects is false, the returned value(s) will be strings containing the files canonical full path on the file system. $bReturnObjects set to true will return FileResource objects which store much more information and can be used to get to things such as the relative path, the directory the relative path was found in, or the frontend path which is used to directly render a file to the user agent. If $bByExpressions and $bFindAll are set to false, only a single string/object is returned (null if not found). Otherwise, an array is returned. If $bFindAll is set, the returned array is index-based; if only $bByExpressions is set, the returned array’s keys are the relative paths of the respective files.
- Parameters
-
array | string | $mRelativePath | relative path to search for in base, plugins or site folders. This can be an array or a string of /-separated directory/file names (or expressions if $bByExpressions is true). |
int | $iFlag | can be one of either ResourceFinder::SEARCH_MAIN_ONLY, ResourceFinder::SEARCH_BASE_ONLY, ResourceFinder::SEARCH_SITE_ONLY, ResourceFinder::SEARCH_PLUGINS_ONLY, ResourceFinder::SEARCH_BASE_FIRST, ResourceFinder::SEARCH_SITE_FIRST, ResourceFinder::SEARCH_PLUGINS_FIRST. The *_ONLY constants are – except for SEARCH_PLUGINS_ONLY – just for convenience: since they only find files in specific directories, you might just as well do file_exists(MAIN_DIR.'my/dir'). |
boolean | $bByExpressions | If set, $mRelativePath becomes not a fixed set of names but an array of regular expressions to evaluate against possible matches. This is slow when used on large directories. There are the following values which can be used as part of the expression: ${parent_name} and ${parent_name_camelized} which do exactly what you would expect. For convenience, any array item not starting with a slash is considered to be a regular file name. This means that a slash is the only accepted delimiter. In addition to regular strings and expressions, you can also pass null for a complete wildcard, true to match all files and false for a wildcard matching only directories. Any expression item packed into an array will be optional. An empty array (as an item of $mRelativePath) will match all items recursively (should not be used in frontend-production environments). |
boolean | $bFindAll | If set, all matching files will be returned even if they have the same relative path inside different instance prefixes. Note: when used in conjunction with $bByExpressions, the return value becomes an index-based array since there could be duplicate relative urls. |
boolean | $bReturnObjects | If set, all returned paths become FileResource objects. This is much cheaper than calling new FileResource() on the returned value(s) because a) FileResource objects are used internally by findResource and b) the additional information maintained by FileResource was added when it was already known and does not have to be deducted. |
- Returns
- mixed
static ResourceFinder::findResourceByExpressions |
( |
|
$aExpressions, |
|
|
|
$iFlag = null |
|
) |
| |
|
static |
static ResourceFinder::findResourceObject |
( |
|
$mRelativePath, |
|
|
|
$iFlag = null |
|
) |
| |
|
static |
static ResourceFinder::findResourceObjectByExpressions |
( |
|
$aExpressions, |
|
|
|
$iFlag = null |
|
) |
| |
|
static |
static ResourceFinder::findResourceObjectsByExpressions |
( |
|
$aExpressions, |
|
|
|
$iFlag = null |
|
) |
| |
|
static |
static ResourceFinder::findResourcesByExpressions |
( |
|
$aExpressions, |
|
|
|
$iFlag = null |
|
) |
| |
|
static |
static ResourceFinder::parsePathArguments |
( |
|
$sBaseDirname = null , |
|
|
|
$mPath = null , |
|
|
|
$sFileName = null |
|
) |
| |
|
static |
Helper function for classes that are given a filename, base path and path name.
ResourceFinder::searchBaseFirst |
( |
| ) |
|
ResourceFinder::searchBaseOnly |
( |
| ) |
|
ResourceFinder::searchMainOnly |
( |
| ) |
|
ResourceFinder::searchPluginsFirst |
( |
| ) |
|
ResourceFinder::searchPluginsOnly |
( |
| ) |
|
ResourceFinder::searchSiteFirst |
( |
| ) |
|
ResourceFinder::searchSiteOnly |
( |
| ) |
|
The documentation for this class was generated from the following file:
- cms-full/base/lib/classes/ResourceFinder.php