PHP Класс Habari\URL

Наследование: extends Singleton
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
ajax ( string $context, array | string | object $args = [] ) : string Helper method for ajax rule
auth_ajax ( string $context, array | string | object $args = [] ) : string Helper method for auth_ajax rule
extract_args ( mixed $args, string $prefix = '' ) : array Extract the possible arguments to use in the URL from the passed variable
get ( mixed $rule_names = '', mixed $args = [], boolean $useall = true, boolean $noamp = false, boolean $prepend_site = true ) : string Builds the required pretty URL given a supplied rule name and a set of placeholder replacement values and returns the built URL.
get_active_rules ( ) : array Get the active RewriteRules that are cached in self::load_rules().
get_from_filesystem ( string $path, string | boolean $trail = false, boolean $preserve_file = false ) : string Get a fully-qualified URL from a filesystem path
get_matched_rule ( ) : RewriteRule Get the matched RewriteRule that was matched in parse().
out ( string $rule_name = null, array $args = [], boolean $useall = true, boolean $noamp = true, boolean $prepend_site = true ) : void Helper wrapper function. Outputs the URL via echo.
parse ( string $from_url ) : RewriteRule Match a URL/URI against the rewrite rules stored in the DB.
set_404 ( ) : RewriteRule Cause the matched rule to be unset in the case of a 404

Защищенные методы

Метод Описание
instance ( ) Enables singleton working properly

Приватные методы

Метод Описание
load_rules ( ) A simple caching mechanism to avoid reloading rule array

Описание методов

ajax() публичный статический Метод

Helper method for ajax rule
public static ajax ( string $context, array | string | object $args = [] ) : string
$context string The context of the ajax rule
$args array | string | object The arguments to pass to the rule's builder
Результат string The resultant URL

auth_ajax() публичный статический Метод

Helper method for auth_ajax rule
public static auth_ajax ( string $context, array | string | object $args = [] ) : string
$context string The context of the ajax rule
$args array | string | object The arguments to pass to the rule's builder
Результат string The resultant URL

extract_args() публичный статический Метод

Extract the possible arguments to use in the URL from the passed variable
public static extract_args ( mixed $args, string $prefix = '' ) : array
$args mixed An array of values or a URLProperties object with properties to use in the construction of a URL
$prefix string
Результат array Properties to use to construct a URL

get() публичный статический Метод

URL::get( 'display_entries_by_date', array( 'year' => '2000', 'month' => '05', 'day' => '01', ) );
public static get ( mixed $rule_names = '', mixed $args = [], boolean $useall = true, boolean $noamp = false, boolean $prepend_site = true ) : string
$rule_names mixed string name of the rule or array of rules which would build the URL
$args mixed (optional) array or object of placeholder replacement values
$useall boolean If true (default), then all passed parameters that are not part of the built URL are tacked onto the URL as querystring
$noamp boolean
$prepend_site boolean If true (default), a full URL is returned, if false, only the path part of the URL is returned
Результат string

get_active_rules() публичный статический Метод

Get the active RewriteRules that are cached in self::load_rules().
public static get_active_rules ( ) : array
Результат array RewriteRules active rules, or null

get_from_filesystem() публичный статический Метод

Get a fully-qualified URL from a filesystem path
public static get_from_filesystem ( string $path, string | boolean $trail = false, boolean $preserve_file = false ) : string
$path string The filesystem path
$trail string | boolean If true, include a trailing slash. If string, append this to the requested url. Default: Add nothing.
$preserve_file boolean If true, leave the filename on the URL. Default: Remove filename.
Результат string URL

get_matched_rule() публичный статический Метод

Get the matched RewriteRule that was matched in parse().
public static get_matched_rule ( ) : RewriteRule
Результат RewriteRule matched rule, or null

instance() защищенный статический Метод

Enables singleton working properly
protected static instance ( )

out() публичный статический Метод

Helper wrapper function. Outputs the URL via echo.
public static out ( string $rule_name = null, array $args = [], boolean $useall = true, boolean $noamp = true, boolean $prepend_site = true ) : void
$rule_name string name of the rule which would build the URL
$args array (optional) array of placeholder replacement values
$useall boolean If true (default), then all passed parameters that are not part of the built URL are tacked onto the URL as querystring
$noamp boolean
$prepend_site boolean If true (default), a full URL is returned, if false, only the path part of the URL is returned
Результат void

parse() публичный статический Метод

This method is used by the Controller class for parsing requests, and by other classes, such as Pingback, which uses it to determine the post slug for a given URL. Returns the matched RewriteRule object, or false.
public static parse ( string $from_url ) : RewriteRule
$from_url string URL string to parse
Результат RewriteRule matched rule, or false

set_404() публичный статический Метод

Cause the matched rule to be unset in the case of a 404
public static set_404 ( ) : RewriteRule
Результат RewriteRule A rewrite rule that represents a 404 error - no match on the URL requested