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.
Property | Type | Description |
---|---|---|
$component | mixed |
mixed
A component to find the plugin for. |
Returns the plugin object or null.
public hasComponent (string $name) : bool
Checks to see if a component has been registered.
Property | Type | Description |
---|---|---|
$name | string |
string
A component class name or code. |
Returns true if the component is registered, otherwise false.
public listComponentDetails () : array
Returns an array of all component detail definitions.
Array keys are component codes, values are the details defined in the component.
public listComponents () : array
Returns a list of registered components.
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.
Property | Type | Description |
---|---|---|
$name | string |
string
A component class name or code. |
$cmsObject | CmsObject |
CmsObject
The Cms object that spawned this component. |
$properties | array |
array
The properties set by the Page or Layout. |
$isSoftComponent | boolean |
boolean
Defines if this is a soft component. |
The component object.
public
registerComponent ($className, $code = null
, $plugin = null
)
Registers a single component.
Property | Type | Description |
---|---|---|
$className | mixed |
mixed
|
$code | mixed |
mixed
|
$plugin | mixed |
mixed
|
public registerComponents (callable $definitions) : array
Manually registers a component for consideration. Usage:
ComponentManager::registerComponents(function ($manager) { $manager->registerComponent('Winter\Demo\Components\Test', 'testComponent'); });
Property | Type | Description |
---|---|---|
$definitions | callable |
callable
|
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.
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
The class name resolved, or null.
protected loadComponents () : void
Scans each plugin an loads it's components.
inherited public __clone ()
inherited public __wakeup ()
inherited
public
static
final
forgetInstance ($container = null
)
: void
Forget this singleton's instance if it exists
Property | Type | Description |
---|---|---|
$container | mixed |
mixed
|
inherited
public
static
final
instance ($container = null
)
: static
Create a new instance of this singleton.
Property | Type | Description |
---|---|---|
$container | mixed |
mixed
|
inherited protected final __construct ()
Constructor.
inherited protected init ()
Initialize the singleton free from constructor parameters.