Types_Manager implements Registerable, JsonSerializable

Manages discount types.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Registerable
JsonSerializable

Table of Contents

$types  : array<string|int, mixed>
All registered types.
add_type()  : self
Add a type of discount.
all()  : array<string|int, mixed>
Get all registered types.
get_by_class()  : array<string|int, mixed>|null
Get a type by its class name.
get_by_slug()  : array<string|int, mixed>|null
Get a type by its slug.
jsonSerialize()  : array<string|int, mixed>
Returns the json object for the types.
register()  : void
Register types of discounts.

Properties

$types

All registered types.

protected array<string|int, mixed> $types = []

Methods

add_type()

Add a type of discount.

public add_type(string $type_class) : self
Parameters
$type_class : string

The class name of the type.

Tags
throws
InvalidArgumentException

If the type is not an instance of Type.

Return values
self

all()

Get all registered types.

public all() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_by_class()

Get a type by its class name.

public get_by_class(string $type_class) : array<string|int, mixed>|null
Parameters
$type_class : string

The class name of the type.

Return values
array<string|int, mixed>|null

get_by_slug()

Get a type by its slug.

public get_by_slug(string $slug) : array<string|int, mixed>|null
Parameters
$slug : string

The slug of the type.

Return values
array<string|int, mixed>|null

jsonSerialize()

Returns the json object for the types.

public jsonSerialize() : array<string|int, mixed>

This is used in the admin settings page.

Return values
array<string|int, mixed>

register()

Register types of discounts.

public register() : void
Return values
void

Search results