PHP Class Habari\RewriteRules

Inheritance: extends ArrayObject
Show file Open project: habari/system

Protected Properties

Property Type Description
$sorted_rules_cache cache sorted rules

Public Methods

Method Description
add_system_rules ( array $rules ) : array Add pre-defined rules to an array of rules only if rules with their names don't already exist
by_name ( string $name ) : array Get a RewriteRule by its name
get_active ( ) : array Return the active rewrite rules, both in the database and applied by plugins
sort_rules ( array $rewrite_rules ) : array Helper function for sorting rewrite rules by priority.

Method Details

add_system_rules() public static method

Add pre-defined rules to an array of rules only if rules with their names don't already exist
public static add_system_rules ( array $rules ) : array
$rules array An array of RewriteRule objects
return array An array of rules with the system rules potentially added

by_name() public static method

Get a RewriteRule by its name
public static by_name ( string $name ) : array
$name string The name of the rule
return array An array of all matched RewriteRule objects.

get_active() public static method

Return the active rewrite rules, both in the database and applied by plugins
public static get_active ( ) : array
return array Array of RewriteRule objects for active rewrite rules

sort_rules() public static method

Required because plugins would insert their rules at the end of the array, which would allow any other rule (including the one that executes by default when no other rules work) to execute first.
public static sort_rules ( array $rewrite_rules ) : array
$rewrite_rules array An array of RewriteRules
return array Sorted rewrite rules by priority

Property Details

$sorted_rules_cache protected static property

cache sorted rules
protected static $sorted_rules_cache