Skip to main content

URL lib

This guide provides documentation for the url class methods used in the AVRO framework.

init()

Parameters: object $config

Usage Example:

$this->lib->url->init(...);
$this->lib->url->init(null); // False
$this->lib->url->init(); // True

subdomain()

Parameters: None

Usage Example:

$this->lib->url->subdomain(); // Return subdomain or False if not exist

language_prefix()

Return language code: en, ru, ...

Parameters: None

Usage Example:

$this->lib->url->language_prefix(); //Return string

allowed_languages()

Return an array with allowed language code: ['en', 'ru', ...]

Parameters: None

Usage Example:

$this->lib->url->allowed_languages(); // Return an array

language_parsing()

Return true if language parsing from query string, and false if not parsing from query string

Parameters: None

Usage Example:

$this->lib->url->language_parsing(); // Return bool

mode()

Return frontend | backend

Parameters: None

Usage Example:

$this->lib->url->mode(); // Return string

backend_dir()

Return the backend directory name defined in the application configuration

Parameters: None

Usage Example:

$this->lib->url->backend_dir(); // Return string

base_url()

Return base url

Parameters: None

Usage Example:

$this->lib->url->base_url(); // Return string

addon()

Return detected addon

Parameters: None

Usage Example:

$this->lib->url->addon(); // Return string

action()

Return detected action

Parameters: None

Usage Example:

$this->lib->url->action();  // Return string

query_string()

Return query string

Parameters: None

Usage Example:

$this->lib->url->query_string(); // Return string

is_https()

Return true if the request protocol is https

Parameters: None

Usage Example:

$this->lib->url->is_https(); // Return bool

dynamic_url()

Generate and return server url

Parameters: None

Usage Example:

$this->lib->url->dynamic_url(); // Return string

parts()

Return exploded parts from url

Parameters: int $index = NULL

Usage Example:

$this->lib->url->parts(...);
$this->lib->url->parts('Hello'); // False url nit exist
$this->lib->url->parts(10); // False, if 11 part in
$this->lib->url->parts(0); // Return first part

parts_count()

Return count of url parts

Parameters: None

Usage Example:

$this->lib->url->parts_count(); // Return int

params()

Return parameter value by item or parameters array Example https://my_host_name/addon_name/action_name/id/17/name/Mike

Parameters: string $item = NULL

Usage Example:

$this->lib->url->params(...);
$this->lib->url->params('unknown'); // False
$this->lib->url->params('id'); // 17
$this->lib->url->params('name'); // Mike
$this->lib->url->params(); // ['id' => '17', 'name' => 'Mike']

params_count()

Return count of parameters

Parameters: None

Usage Example:

$this->lib->url->params_count(); // Return int

set_language_prefix()

Parameters: string $lp

Usage Example:

$this->lib->url->set_language_prefix(...);
$this->lib->url->set_language_prefix(''); // False
$this->lib->url->set_language_prefix('invalid'); // False
$this->lib->url->set_language_prefix('en'); // True
$this->lib->url->set_language_prefix('hy'); // True

set_addon()

Parameters: string $addon

Usage Example:

$this->lib->url->set_addon(...);
$this->lib->url->set_addon(''); // False
$this->lib->url->set_addon('user'); // True

set_action()

Parameters: string $action

Usage Example:

$this->lib->url->set_action(...);
$this->lib->url->set_action(''); // False
$this->lib->url->set_action('login'); // True

set_mode()

Set application mode 'frontend' | 'backend'

Parameters: string $mode

Usage Example:

$this->lib->url->set_mode(...);
$this->lib->url->set_mode(''); // False
$this->lib->url->set_mode('unknown_mode'); // False
$this->lib->url->set_mode('backend'); // True
$this->lib->url->set_mode('frontend'); // True