Component manager

Protected properties

protected array $callbacks

Cache of registration callbacks.

protected array $codeMap

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

protected array $classMap

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

protected array $pluginMap

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

protected array $detailsCache

A cached array of component details.

protected static $instance

Public methods

public void __clone()

public void __wakeup()

public mixed findComponentPlugin(mixed $component)

Returns a parent plugin for a specific component object.

  • mixed $component - A component to find the plugin for.

public static void forgetInstance()

Forget this singleton's instance if it exists

public bool hasComponent(string $name)

Checks to see if a component has been registered.

  • string $name - A component class name or code.

public static void instance()

Create a new instance of this singleton.

public array listComponentDetails()

Returns an array of all component detail definitions.

public array listComponents()

Returns a list of registered components.

public ComponentBase makeComponent(string $name, CmsObject $cmsObject=NULL, array $properties=array())

Makes a component object with properties set.

  • string $name - A component class name or code.
  • CmsObject $cmsObject - The Cms object that spawned this component.
  • array $properties - The properties set by the Page or Layout.

public void registerComponent($className, $code=NULL, $plugin=NULL)

Registers a single component.

  • $className
  • $code
  • $plugin

public array registerComponents(callable $definitions)

Manually registers a component for consideration. Usage:

ComponentManager::registerComponents(function ($manager) {
    $manager->registerComponent('October\Demo\Components\Test', 'testComponent');
  • callable $definitions

public string resolve($name)

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

  • $name

Protected methods

protected void __construct()


protected void init()

Initialize the singleton free from constructor parameters.

protected void loadComponents()

Scans each plugin an loads it's components.