abstract class Component implements IComponent

Base class for all components. Components have a parent, name, and can be monitored by ancestors.

Methods

IComponent|null
lookup(string|null $type, bool $throw = true)

Finds the closest ancestor of specified type.

string|null
lookupPath(string|null $type = null, bool $throw = true)

Finds the closest ancestor specified by class or interface name and returns backtrace path.

void
monitor(string $type, callable|null $attached = null, callable|null $detached = null)

Starts monitoring ancestors for attach/detach events.

void
unmonitor(string $type)

Stops monitoring ancestors of specified type.

string|null
getName()

No description

IContainer|null
getParent()

Returns the parent container if any.

setParent(IContainer|null $parent, string|null $name = null)

Sets or removes the parent of this component. This method is managed by containers and should not be called by applications

void
validateParent(IContainer $parent)

Validates the new parent before it's set.

__clone()

Object cloning.

__serialize()

Prevents serialization.

Details

at line 39
final IComponent|null lookup(string|null $type, bool $throw = true)

Finds the closest ancestor of specified type.

Parameters

string|null $type
bool $throw

throw exception if component doesn't exist?

Return Value

IComponent|null

at line 81
final string|null lookupPath(string|null $type = null, bool $throw = true)

Finds the closest ancestor specified by class or interface name and returns backtrace path.

A path is the concatenation of component names separated by self::NameSeparator.

Parameters

string|null $type
bool $throw

throw exception if component doesn't exist?

Return Value

string|null

at line 95
final void monitor(string $type, callable|null $attached = null, callable|null $detached = null)

Starts monitoring ancestors for attach/detach events.

Parameters

string $type
callable|null $attached
callable|null $detached

Return Value

void

at line 121
final void unmonitor(string $type)

Stops monitoring ancestors of specified type.

Parameters

string $type

Return Value

void

at line 130
final string|null getName()

No description

Return Value

string|null

at line 139
final IContainer|null getParent()

Returns the parent container if any.

Return Value

IContainer|null

at line 151
IComponent setParent(IContainer|null $parent, string|null $name = null)

internal  
 

Sets or removes the parent of this component. This method is managed by containers and should not be called by applications

Parameters

IContainer|null $parent
string|null $name

Return Value

IComponent

Exceptions

InvalidStateException

at line 191
protected void validateParent(IContainer $parent)

Validates the new parent before it's set.

Descendant classes can override this to implement custom validation logic.

Parameters

IContainer $parent

Return Value

void

Exceptions

InvalidStateException

at line 279
__clone()

Object cloning.

at line 299
final __serialize()

Prevents serialization.