Cms\Classes\ComponentManager


Protected Properties

protected array $codeMap

codeMap where keys are codes and values are class names.

protected array $classMap

classMap where keys are class names and values are codes.

protected array $ownerDetailsMap

ownerDetailsMap with owner information about a component.

protected array $ownerMap

ownerMap where keys are class name and values are owner class.

protected array $detailsCache

detailsCache array of component details.


Public Methods

public findComponentOwnerDetails()

public findComponentOwnerDetails($component): array 

findComponentOwnerDetails returns details about the component owner as an array.

public hasComponent()

public hasComponent(string $name): bool 

hasComponent checks to see if a component has been registered.

public static instance()

public static instance(): static 

instance creates a new instance of this singleton

public listComponentDetails()

public listComponentDetails(): array 

listComponentDetails returns an array of all component detail definitions. Returns array keys as component codes and values as the details defined in the component.

public listComponentOwnerDetails()

public listComponentOwnerDetails(): void

listComponentOwnerDetails returns the components grouped by owner and injects the owner details.

public listComponents()

public listComponents(): array 

listComponents returns a list of registered components. Returns array keys as codes and values as class names.

public makeComponent()

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

makeComponent object with properties set.

public registerComponent()

public registerComponent($className, $code = null, $owner = null): void

registerComponent registers a single component.

public registerComponents()

public registerComponents(callable $callback): void

registerComponents manually registers a component for consideration. Usage:

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

public resolve()

public resolve($name): string 

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

Protected Methods

protected loadComponents()

protected loadComponents(): void

loadComponents scans each plugin an loads it's components.

protected loadComponentsFromArray()

protected loadComponentsFromArray($items, $owner = null): void

loadComponentsFromArray helper

protected setComponentOwnerAsPlugin()

protected setComponentOwnerAsPlugin($code, $className, $pluginObj): void 

protected setComponentOwnerAsProvider()

protected setComponentOwnerAsProvider($code, $className, $providerObj): void