ComponentManager

Component manager

 class Cms\Classes\ComponentManager

Traits

Trait Description
Singleton

Singleton trait.

Properties

protected $callbacks : array

Cache of registration callbacks.

protected $classMap : array

An array where keys are class names and values are codes.

protected $codeMap : array

An array where keys are codes and values are class names.

protected $detailsCache : array

A cached array of component details.

protected $pluginMap : array

An array containing references to a corresponding plugin for each component class.

Methods

public findComponentPlugin (mixed $component) : mixed

Returns a parent plugin for a specific component object.

Parameters
Property Description
$component
mixed

A component to find the plugin for.

Returns
mixed

Returns the plugin object or null.

public hasComponent (string $name) : bool

Checks to see if a component has been registered.

Parameters
Property Description
$name
string

A component class name or code.

Returns
bool

Returns true if the component is registered, otherwise false.

public listComponentDetails () : array

Returns an array of all component detail definitions.

Returns
array

Array keys are component codes, values are the details defined in the component.

public listComponents () : array

Returns a list of registered components.

Returns
array

Array keys are codes, values are class names.

public makeComponent (string $name, CmsObject $cmsObject = null, array $properties = [], boolean $isSoftComponent = false) : ComponentBase

Makes a component object with properties set.

Parameters
Property Description
$name
string

A component class name or code.

$cmsObject
CmsObject

The Cms object that spawned this component.

$properties
array

The properties set by the Page or Layout.

$isSoftComponent
boolean

Defines if this is a soft component.

Returns
ComponentBase

The component object.

public registerComponent ($className, $code = null, $plugin = null)

Registers a single component.

Parameters
Property Description
$className
mixed
$code
mixed
$plugin
mixed
Returns
mixed

public registerComponents (callable $definitions) : array

Manually registers a component for consideration. Usage:

ComponentManager::registerComponents(function ($manager) { $manager->registerComponent('Winter\Demo\Components\Test', 'testComponent'); });

Parameters
Property Description
$definitions
callable
Returns
array

Array values are class names.

public resolve ($name) : string

Returns a class name from a component code Normalizes a class name or converts an code to it's class name.

Parameters
Property Description
$name
mixed
Returns
string

The class name resolved, or null.

protected loadComponents () : void

Scans each plugin an loads it's components.

Returns
void

inherited public __clone ()

Inherited from Singleton
Returns
mixed

inherited public __wakeup ()

Inherited from Singleton
Returns
mixed

inherited public static final forgetInstance ($container = null) : void

Inherited from Singleton

Forget this singleton's instance if it exists

Parameters
Property Description
$container
mixed
Returns
void

inherited public static final instance ($container = null) : static

Inherited from Singleton

Create a new instance of this singleton.

Parameters
Property Description
$container
mixed
Returns
static

inherited protected final __construct ()

Inherited from Singleton

Constructor.

Returns
mixed

inherited protected init ()

Inherited from Singleton

Initialize the singleton free from constructor parameters.

Returns
mixed
Copyright © 2024 Winter CMS