abstract class Component implements IComponent

Component is the base class for all components.

Components are objects implementing IComponent. They has parent component and own name.

Properties

string read-only $name
IContainer|null read-only $parent

Methods

__construct()

No description

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

Finds the closest ancestor specified by class or interface name.

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 $attached = null, callable $detached = null)

Starts monitoring of ancestors.

void
unmonitor(string $type)

Stops monitoring of ancestors.

void
attached(IComponent $obj) deprecated

This method will be called when the component (or component's parent) becomes attached to a monitored object. Do not call this method yourself.

void
detached(IComponent $obj) deprecated

This method will be called before the component (or component's parent) becomes detached from a monitored object. Do not call this method yourself.

string|null
getName()

No description

IContainer|null
getParent()

Returns the parent container if any.

setParent(IContainer $parent = null, string $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)

Is called by a component when it is about to be set new parent. Descendant can override this method to disallow a parent change by throwing an Nette\InvalidStateException

__clone()

Object cloning.

__sleep()

Prevents serialization.

__wakeup()

Prevents unserialization.

Details

at line 35
__construct()

No description

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

Finds the closest ancestor specified by class or interface name.

Parameters

string|null $type
bool $throw

Return Value

IComponent|null

at line 97
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::NAME_SEPARATOR.

Parameters

string|null $type
bool $throw

Return Value

string|null

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

Starts monitoring of ancestors.

Parameters

string $type
callable $attached
callable $detached

Return Value

void

at line 127
void unmonitor(string $type)

Stops monitoring of ancestors.

Parameters

string $type

Return Value

void

at line 140
protected void attached(IComponent $obj) deprecated

deprecated use monitor($type, $attached)

This method will be called when the component (or component's parent) becomes attached to a monitored object. Do not call this method yourself.

Parameters

IComponent $obj

Return Value

void

at line 152
protected void detached(IComponent $obj) deprecated

deprecated use monitor($type, null, $detached)

This method will be called before the component (or component's parent) becomes detached from a monitored object. Do not call this method yourself.

Parameters

IComponent $obj

Return Value

void

at line 163
string|null getName()

No description

Return Value

string|null

at line 173
IContainer|null getParent()

Returns the parent container if any.

Return Value

IContainer|null

at line 187
IComponent setParent(IContainer $parent = null, string $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 $parent
string $name

Return Value

IComponent

Exceptions

InvalidStateException

at line 227
protected void validateParent(IContainer $parent)

Is called by a component when it is about to be set new parent. Descendant can override this method to disallow a parent change by throwing an Nette\InvalidStateException

Parameters

IContainer $parent

Return Value

void

Exceptions

InvalidStateException

at line 306
__clone()

Object cloning.

at line 327
__sleep()

Prevents serialization.

at line 336
__wakeup()

Prevents unserialization.

Traits

SmartObject