Static Public Member Functions | |
static | execute ($req, $mode=self::MODE_METADATA) |
Executes a search request. | |
static | grep ($pattern, $domain= '//', $types=array(), $options=array(), $statuses=array()) |
Searches for content using regular expressions. |
To use this class, create a SnapSearchRequest object, fill it with the search parameters and then call SnapSearch::execute() with the object to get the results. This class also supports grepping of content with regular expressions (SnapSearch::grep()).
static SnapSearch::execute | ( | $ | req, | |
$ | mode = self::MODE_METADATA | |||
) | [static] |
Executes a search request.
Build a SnapSearchRequest object first, and pass it to this method to get the results. You can get the results in several formats based on what you pass in the 2nd argument:
MODE_LIST
: array of paths for each matching filesystem object, along with some additional informationMODE_METADATA
: like MODE_LIST, but include the complete file metadata in the result arrayMODE_ALL
: same as MODE_METADATA, but include version content (which would otherwise be excluded)MODE_OBJECTS
: return Snap2 objectsMODE_ALL_OBJECTS
: combines MODE_OBJECTS and MODE_ALL$req | [SnapSearchRequest]: request object that defines the search criteria | |
$mode | [int]: one of the MODE_* constants as described above |
static SnapSearch::grep | ( | $ | pattern, | |
$ | domain = '//' , |
|||
$ | types = array() , |
|||
$ | options = array() , |
|||
$ | statuses = array() | |||
) | [static] |
Searches for content using regular expressions.
This method takes a pattern and some options and finds versions that have content that matches the regular expression pattern provided. The $options parameter is an array that may contain zero or more of the following constants:
GREP_CASE_INSENSITIVE
: do a case-insensitive match (like the '/i' flag on regexes)GREP_MULTILINE
: makes '^
' and '$
' match beginning and end of line instead of beginning and end of stringGREP_MATCH_NEWLINE
: makes '.
' match newline characters (default is not to)GREP_MATCH_ALL
: include all matches from a version, not just that the version matchedIf GREP_MATCH_ALL is used, the method returns an array indexed by path for each matching version. The value of each array is a sub-array that contains a list of two-element arrays, where the first element is the entire line (or set of lines) containing the match and the second element is just the portion of the line that matched.
$pattern | [string]: regular expression pattern to match | |
$domain | [string]: path to directory or resource under which to search versions for pattern | |
$types | [array]: list of content types that should be searched (see SnapResource) | |
$options | [array]: one of the GREP_* constants as described above | |
$statuses | [array]: list of version statuses that should be searched (see SnapVersion) |