PostTypes
in package
implements
RegistryInterface
uses
RegistryTrait
PostTypes Registry class.
Abstract class for managing PostType instances in a centralized registry. Supports adding, retrieving, and removing instances.
Tags
Table of Contents
Interfaces
Properties
- $components : array<string|int, mixed>
- A static array holding the registered components, keyed by their unique hash ID.
Methods
- add() : string
- Adds a component to the registry and returns its unique hash ID.
- get() : mixed|null
- Retrieves a component from the registry by its unique hash ID.
- get_all() : array<string|int, mixed>
- Returns all components currently stored in the registry.
- remove() : mixed
- Removes a component from the registry by its unique hash ID.
Properties
$components
A static array holding the registered components, keyed by their unique hash ID.
protected
static array<string|int, mixed>
$components
= []
Methods
add()
Adds a component to the registry and returns its unique hash ID.
public
static add(mixed $component) : string
This method ensures that the component is stored in the registry and that a unique hash ID is generated for it. The hash ID is returned to the caller for easy access.
Parameters
- $component : mixed
-
The component to add to the registry. Can be any data type.
Return values
string —The unique hash ID generated for the component.
get()
Retrieves a component from the registry by its unique hash ID.
public
static get(string $key) : mixed|null
If the component is found, it is returned; otherwise, null is returned. This method allows for easy access to components stored in the registry.
Parameters
- $key : string
-
The unique hash ID of the component to retrieve.
Return values
mixed|null —The component associated with the hash ID, or null if not found.
get_all()
Returns all components currently stored in the registry.
public
static get_all() : array<string|int, mixed>
This method provides a way to access all registered components at once, returning them as an associative array keyed by their unique hash IDs.
Return values
array<string|int, mixed> —An associative array of all components in the registry.
remove()
Removes a component from the registry by its unique hash ID.
public
static remove(string $key) : mixed
This method ensures that the component is no longer available in the registry. It is useful for cleanup operations or when a component is no longer needed.
Parameters
- $key : string
-
The unique hash ID of the component to remove.