Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
Registry Class Reference

Handles creating objects and calling methods. More...

Public Member Functions

array< string, $legacyTypes=['Cache'=> __construct ()
 Constructor.
 
call ($type, $method, $parameters=[])
 Call a static method for a type.
 
create ($type, $parameters=[])
 Create a new instance of a given type.
 
 get_class ($type)
 Get the class registered for a type.
 
 register ($type, $class, $legacy=false)
 Register a class.
 

Protected Attributes

array $classes = []
 Class mapping.
 
array< class-string > $legacy = []
 Legacy classes.
 

Detailed Description

Handles creating objects and calling methods.

Access this via {

See also
SimplePie\SimplePie\get_registry()}

Constructor & Destructor Documentation

◆ __construct()

array< string, $legacyTypes=[ 'Cache'=> Registry::__construct ( )

Constructor.

No-op

Member Function Documentation

◆ call()

& Registry::call ( $type,
$method,
$parameters = [] )

Call a static method for a type.

Parameters
class-string$type
string$method
array$parameters
Return values
mixed

◆ create()

& Registry::create ( $type,
$parameters = [] )

Create a new instance of a given type.

@template T class-string $type

Parameters
class-string<T>$type
array$parametersParameters to pass to the constructor
Return values
TInstance of class

◆ get_class()

Registry::get_class ( $type)

Get the class registered for a type.

Where possible, use {

See also
create()} or {
call()} instead

@template T

Parameters
class-string<T>$type
Return values
class-string<T>|null

◆ register()

Registry::register ( $type,
$class,
$legacy = false )

Register a class.

Parameters
string$typeSee {
See also
$default} for names
Parameters
class-string$classClass name, must subclass the corresponding default
bool$legacyWhether to enable legacy support for this class
Return values
boolSuccessfulness

Member Data Documentation

◆ $classes

array Registry::$classes = []
protected

Class mapping.

See also
register()

◆ $legacy

array<class-string> Registry::$legacy = []
protected

Legacy classes.

See also
register()

The documentation for this class was generated from the following file: