PHP Class Mercator\Mapping

Afficher le fichier Open project: humanmade/mercator Class Usage Examples

Protected Properties

Свойство Type Description
$data array Mapping data
$site integer Site ID

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
__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

Method Details

__clone() public méthode

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

__construct() protected méthode

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

create() public static méthode

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
Résultat Mapping | WP_Error

delete() public méthode

Delete the mapping
public delete ( ) : boolean | WP_Erro\WP_Error
Résultat boolean | WP_Erro\WP_Error True if we updated, false if we didn't need to, or WP_Error if an error occurred

get() public static méthode

Get mapping by mapping ID
public static get ( integer | Mapping $mapping ) : Mapping | WP_Erro\WP_Error | null
$mapping integer | Mapping Mapping ID or instance
Résultat Mapping | WP_Erro\WP_Error | null Mapping on success, WP_Error if error occurred, or null if no mapping found

get_by_domain() public static méthode

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
Résultat Mapping | WP_Erro\WP_Error | null Mapping on success, WP_Error if error occurred, or null if no mapping found

get_by_site() public static méthode

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}
Résultat Mapping | WP_Erro\WP_Error | null Mapping on success, WP_Error if error occurred, or null if no mapping found

get_domain() public méthode

Get the domain from the mapping
public get_domain ( ) : string
Résultat string

get_id() public méthode

Get mapping ID
public get_id ( ) : integer
Résultat integer Mapping ID

get_site() public méthode

Get site object
public get_site ( ) : stdClass | boolean
Résultat stdClass | boolean {@see \get_blog_details}

get_site_id() public méthode

Get site ID
public get_site_id ( ) : integer
Résultat integer Site ID

is_active() public méthode

Is the mapping active?
public is_active ( ) : boolean
Résultat boolean

make_primary() public méthode

Make this mapping the primary domain, eg. set the homeurl for the site
public make_primary ( ) : boolean | WP_Error
Résultat boolean | WP_Error True if we created the old mapping or WP_Error if an error occurred

set_active() public méthode

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)
Résultat 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() public méthode

Set the domain for the mapping
public set_domain ( string $domain ) : boolean | WP_Erro\WP_Error
$domain string Domain name
Résultat 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() protected static méthode

Allows use as a callback, such as in array_map
protected static to_instance ( stdClass $data ) : Mapping
$data stdClass Raw mapping data
Résultat Mapping

to_instances() protected static méthode

Convert list of data to Mapping instances
protected static to_instances ( stdClass[] $data ) : Mapping[]
$data stdClass[] Raw mapping rows
Résultat Mapping[]

update() public méthode

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)
Résultat boolean | WP_Erro\WP_Error True if we updated, false if we didn't need to, or WP_Error if an error occurred

Property Details

$data protected_oe property

Mapping data
protected array $data
Résultat array

$site protected_oe property

Site ID
protected int $site
Résultat integer