class ComponentManager

Components class for TastyIgniter.

Provides utility functions for working with components.

Traits

Singleton trait.

Properties

static protected $instance from  Singleton
array $registry
protected array $componentsCallbacks
protected array $codeMap
protected array $classMap
protected array $extensionMap
protected array $components

Methods

static 
instance()

Create a new instance of this singleton.

static 
forgetInstance()

Forget this singleton's instance if it exists

__construct()

Constructor.

initialize()

Initialize the singleton free from constructor parameters.

__clone()

No description

__wakeup()

No description

void
loadComponents()

Scans each extension and loads it components.

void
registerComponents(callable $definitions)

Manually registers a component.

registerComponent(string $class_path, array $component = null, object $extension = null)

Registers a single component.

array
listComponents()

Returns a list of registered components.

string
resolve(string $name)

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

bool
hasComponent(string $name)

Checks to see if a component has been registered.

mixed|null
findComponent($name)

Returns component details based on its name.

mixed|null
getMeta($name)

Returns payment gateway details based on its name.

makeComponent(string $name, PageCode $page = null, array $params = [])

Makes a component/gateway object with properties set.

mixed
findComponentExtension(mixed $component)

Returns a parent extension for a specific component.

string
convertCodeToPath(string $alias)

Convert class alias to class path

array
getComponentPropertyConfig(mixed $component, bool $addAliasProperty = true)

Returns a component property configuration as a JSON string or array.

array
getComponentPropertyValues(mixed $component)

Returns a component property values.

getComponentPropertyRules($component)

No description

checkComponentPropertyType($type)

No description

Details

in Singleton at line 18
final static instance()

Create a new instance of this singleton.

in Singleton at line 28
final static forgetInstance()

Forget this singleton's instance if it exists

in Singleton at line 36
final protected __construct()

Constructor.

in Singleton at line 44
protected initialize()

Initialize the singleton free from constructor parameters.

in Singleton at line 48
__clone()

No description

in Singleton at line 53
__wakeup()

No description

at line 49
protected void loadComponents()

Scans each extension and loads it components.

Return Value

void

at line 87
void registerComponents(callable $definitions)

Manually registers a component.

Usage:

  ComponentManager::instance()->registerComponents(function($manager){
      $manager->registerComponent('account_module/components/Account_module', array(
         'name' => 'account_module',
           'title' => 'Account Component',
           'description' => '..',
       );
  });

Parameters

callable $definitions

Return Value

void

at line 99
registerComponent(string $class_path, array $component = null, object $extension = null)

Registers a single component.

Parameters

string $class_path
array $component
object $extension Extension

at line 136
array listComponents()

Returns a list of registered components.

Return Value

array

Array keys are codes, values are component meta array.

at line 153
string resolve(string $name)

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

Parameters

string $name

Return Value

string

The class name resolved, or null.

at line 176
bool hasComponent(string $name)

Checks to see if a component has been registered.

Parameters

string $name

A component class name or alias.

Return Value

bool

Returns true if the component is registered, otherwise false.

at line 193
mixed|null findComponent($name)

Returns component details based on its name.

Parameters

$name

Return Value

mixed|null

at line 209
mixed|null getMeta($name)

Returns payment gateway details based on its name.

Parameters

$name

Return Value

mixed|null

at line 232
BaseComponent makeComponent(string $name, PageCode $page = null, array $params = [])

Makes a component/gateway object with properties set.

Parameters

string $name

A component/gateway class name or code.

PageCode $page

The page that spawned this component.

array $params

The properties set by the Page or Layout.

Return Value

BaseComponent

The component object.

Exceptions

SystemException

at line 259
mixed findComponentExtension(mixed $component)

Returns a parent extension for a specific component.

Parameters

mixed $component

A component to find the extension for.

Return Value

mixed

Returns the extension object or null.

at line 276
string convertCodeToPath(string $alias)

Convert class alias to class path

Parameters

string $alias

Return Value

string

at line 297
array getComponentPropertyConfig(mixed $component, bool $addAliasProperty = true)

Returns a component property configuration as a JSON string or array.

Parameters

mixed $component

The component object

bool $addAliasProperty

Determines if the Alias property should be added to the result.

Return Value

array

at line 366
array getComponentPropertyValues(mixed $component)

Returns a component property values.

Parameters

mixed $component

The component object

Return Value

array

at line 380
getComponentPropertyRules($component)

No description

Parameters

$component

at line 395
protected checkComponentPropertyType($type)

No description

Parameters

$type