SwatObject
└─SwatAutoloaderRule
public class SwatAutoloaderRule
extends SwatObject
| Constructor Summary | |
|---|---|
SwatAutoloaderRule(string expression, string replacement, boolean last) Creates a new class autoloader rule. |
|
| Method Summary | |
|---|---|
| string | apply(string class_name) Applies this autoloader rule to a class name. |
| boolean | isLast() Whether or not this rule is a final rule. |
public SwatAutoloaderRule(string expression, string replacement, boolean last)
Creates a new class autoloader rule
expression - the expression of this rule. Uses PERL regular expression syntax.replacement - the replacement format string of this rule.last - whether or not this rule is final.public string apply(string class_name)
Applies this autoloader rule to a class name
class_name - the name of the class to apply this rule to.public boolean isLast()
Whether or not this rule is a final rule
A class autoloader rule
Class autoloader rules define how class names map to filenames. An autoloader rule consists of three parts:
The expression of an autoloader rule is a regular expression using PERL syntax that matches a class name in PHP. For example, the expression '/^Swat(*.)$/' matches all Swat classes.
The replacement of an autoloader rule is a string representing the filename format of classes matched by the autoloader expression. The filename format may contain substitution markers denoted by $n where n is the n'th captured parenthesized subpattern. For example, the replacement 'Swat/Swat$1.php' represents the file naming convention for Swat class files. The format of replacement strings is intentionally similar to Apache rewrite rule syntax.
Whether or not an autoloader rule is final determines what happens if a class name matches a rule. If a rule is final, the class name is not checked against any other rules once a match is found. Rules are final by default.