abstract class Module extends Singleton

A class to represent crucial project file system structures and bind their PHP functionalities to WordPress.

Properties

static protected Singleton[] $_instances from  Singleton
protected bool $is_submodule
protected bool $enabled
static string $includes_dir
static string $modules_dir
static array $includes
protected array $loaded_modules

Methods

__construct(bool $is_submodule = false)

A protected constructor to ensure only singleton instances of plugins exist.

static Singleton
instance(mixed $args = null)

Maybe initialize singleton instance and return the instance.

static array
get_instances()

Return a copy of the instances array.

get_class_reflection()

A short one-liner tool to get a ReflectionClass so we can get runtime info for the static class instance and not this abstract.

static 
construct()

An empty, placeholder function for overriding, this is where the module "starts" it's WordPress code.

static 
submodule_construct()

The function which gets called when a module is being constructed. This ensures the submodule construct sequences don't get fired when a submodule is first initialized.

static 
submodule_instance()

The function which gets called if this module is being imported as a submodule.

register_submodules()

Our special function for searching for submodule folders, loading them into the current module and PHP environment.

construct_submodules()

Loop through all loaded modules and run their initialization functions.

import_module(string $module_path)

Given a Module class name and a file path, loads the file into the PHP environment, then checks to make sure the given class extends Module and adds it to { $this->loaded_modules }

string|false
load_class_file(string $file_path)

Load a class from a file and return the full class name.

array
get_loaded_modules()

Get the currently loaded modules.

Details

at line 61
protected __construct(bool $is_submodule = false)

A protected constructor to ensure only singleton instances of plugins exist.

Parameters

bool $is_submodule

in Singleton at line 42
final static Singleton instance(mixed $args = null)

Maybe initialize singleton instance and return the instance.

Parameters

mixed $args

The arguments to pass to the singleton constructor if constructing.

Return Value

Singleton

This instance.

in Singleton at line 63
final static array get_instances()

Return a copy of the instances array.

Return Value

array

A list of Singleton instances that have been instantiated.

in Singleton at line 72
final protected ReflectionClass get_class_reflection()

A short one-liner tool to get a ReflectionClass so we can get runtime info for the static class instance and not this abstract.

Return Value

ReflectionClass

The runtime instance of this class being evalutated.

at line 82
static construct()

An empty, placeholder function for overriding, this is where the module "starts" it's WordPress code.

at line 87
static submodule_construct()

The function which gets called when a module is being constructed. This ensures the submodule construct sequences don't get fired when a submodule is first initialized.

at line 98
final static submodule_instance()

The function which gets called if this module is being imported as a submodule.

at line 105
final protected register_submodules()

Our special function for searching for submodule folders, loading them into the current module and PHP environment.

at line 136
final protected construct_submodules()

Loop through all loaded modules and run their initialization functions.

at line 149
final protected import_module(string $module_path)

Given a Module class name and a file path, loads the file into the PHP environment, then checks to make sure the given class extends Module and adds it to { $this->loaded_modules }

Parameters

string $module_path

The full path/file combination pointing to the module file.

at line 173
final protected string|false load_class_file(string $file_path)

Load a class from a file and return the full class name.

Parameters

string $file_path

The path to the file containing the class.

Return Value

string|false

The fully-qualified class name or FALSE on failure.

at line 225
final array get_loaded_modules()

Get the currently loaded modules.

Return Value

array

The modules currently loaded.