PHP Класс Mercator\Mapping

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

Защищенные свойства (Protected)

Свойство Тип Описание
$data array Mapping data
$site integer Site ID

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

Метод Описание
__clone ( ) Clone magic method when clone( self ) is called.
create ( string $site, string $domain, boolean $active = false ) : Mapping | WP_Error Create a new domain mapping
delete ( ) : boolean | WP_Erro\WP_Error Delete the mapping
get ( integer | Mapping $mapping ) : Mapping | WP_Erro\WP_Error | null Get mapping by mapping ID
get_by_domain ( string | array $domains ) : Mapping | WP_Erro\WP_Error | null Get mapping by domain(s)
get_by_site ( integer | stdClass $site ) : Mapping | WP_Erro\WP_Error | null Get mapping by site ID
get_domain ( ) : string Get the domain from the mapping
get_id ( ) : integer Get mapping ID
get_site ( ) : stdClass | boolean Get site object
get_site_id ( ) : integer Get site ID
is_active ( ) : boolean Is the mapping active?
make_primary ( ) : boolean | WP_Error Make this mapping the primary domain, eg. set the homeurl for the site
set_active ( boolean $active ) : boolean | WP_Erro\WP_Error Set whether the mapping is active
set_domain ( string $domain ) : boolean | WP_Erro\WP_Error Set the domain for the mapping
update ( array | stdClass $data ) : boolean | WP_Erro\WP_Error Update the mapping

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

Метод Описание
__construct ( array $data ) Constructor
to_instance ( stdClass $data ) : Mapping Convert data to Mapping instance
to_instances ( stdClass[] $data ) : Mapping[] Convert list of data to Mapping instances

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

__clone() публичный метод

As the internal data is stored in an object, we have to make a copy when this object is cloned.
public __clone ( )

__construct() защищенный метод

Constructor
protected __construct ( array $data )
$data array Mapping data

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

Create a new domain mapping
public static create ( string $site, string $domain, boolean $active = false ) : Mapping | WP_Error
$site string Site ID, or site object from {@see \get_blog_details}
$domain string
$active boolean
Результат Mapping | WP_Error

delete() публичный метод

Delete the mapping
public delete ( ) : boolean | WP_Erro\WP_Error
Результат boolean | WP_Erro\WP_Error True if we updated, false if we didn't need to, or WP_Error if an error occurred

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

Get mapping by mapping ID
public static get ( integer | Mapping $mapping ) : Mapping | WP_Erro\WP_Error | null
$mapping integer | Mapping Mapping ID or instance
Результат Mapping | WP_Erro\WP_Error | null Mapping on success, WP_Error if error occurred, or null if no mapping found

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

Get mapping by domain(s)
public static get_by_domain ( string | array $domains ) : Mapping | WP_Erro\WP_Error | null
$domains string | array Domain(s) to match against
Результат Mapping | WP_Erro\WP_Error | null Mapping on success, WP_Error if error occurred, or null if no mapping found

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

Get mapping by site ID
public static get_by_site ( integer | stdClass $site ) : Mapping | WP_Erro\WP_Error | null
$site integer | stdClass Site ID, or site object from {@see \get_blog_details}
Результат Mapping | WP_Erro\WP_Error | null Mapping on success, WP_Error if error occurred, or null if no mapping found

get_domain() публичный метод

Get the domain from the mapping
public get_domain ( ) : string
Результат string

get_id() публичный метод

Get mapping ID
public get_id ( ) : integer
Результат integer Mapping ID

get_site() публичный метод

Get site object
public get_site ( ) : stdClass | boolean
Результат stdClass | boolean {@see \get_blog_details}

get_site_id() публичный метод

Get site ID
public get_site_id ( ) : integer
Результат integer Site ID

is_active() публичный метод

Is the mapping active?
public is_active ( ) : boolean
Результат boolean

make_primary() публичный метод

Make this mapping the primary domain, eg. set the homeurl for the site
public make_primary ( ) : boolean | WP_Error
Результат boolean | WP_Error True if we created the old mapping or WP_Error if an error occurred

set_active() публичный метод

Set whether the mapping is active
public set_active ( boolean $active ) : boolean | WP_Erro\WP_Error
$active boolean Should the mapping be active? (True for active, false for inactive)
Результат boolean | WP_Erro\WP_Error True if we updated, false if we didn't need to, or WP_Error if an error occurred

set_domain() публичный метод

Set the domain for the mapping
public set_domain ( string $domain ) : boolean | WP_Erro\WP_Error
$domain string Domain name
Результат boolean | WP_Erro\WP_Error True if we updated, false if we didn't need to, or WP_Error if an error occurred

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

Allows use as a callback, such as in array_map
protected static to_instance ( stdClass $data ) : Mapping
$data stdClass Raw mapping data
Результат Mapping

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

Convert list of data to Mapping instances
protected static to_instances ( stdClass[] $data ) : Mapping[]
$data stdClass[] Raw mapping rows
Результат Mapping[]

update() публичный метод

See also, {@see \set_domain} and {@see \set_active} as convenience methods.
public update ( array | stdClass $data ) : boolean | WP_Erro\WP_Error
$data array | stdClass Mapping fields (associative array or object properties)
Результат boolean | WP_Erro\WP_Error True if we updated, false if we didn't need to, or WP_Error if an error occurred

Описание свойств

$data защищенное свойство

Mapping data
protected array $data
Результат array

$site защищенное свойство

Site ID
protected int $site
Результат integer