class Container extends Component implements IContainer

Manages a collection of child components.

Constants

private NameRegexp

Properties

IComponent[] read-only $components

Methods

addComponent(IComponent $component, string|null $name, string|null $insertBefore = null)

Adds a child component to the container.

void
removeComponent(IComponent $component)

Removes a child component from the container.

IComponent|null
getComponent(string $name, bool $throw = true)

Retrieves a child component by name or creates it if it doesn't exist.

IComponent|null
createComponent(string $name)

Creates a new component. Delegates creation to createComponent method if it exists.

iterable
getComponents()

Returns all immediate child components.

array
getComponentTree()

Retrieves the entire hierarchy of components, including all nested child components (depth-first).

void
validateChildComponent(IComponent $child)

Validates a child component before it's added to the container.

__clone()

Handles object cloning. Clones all child components and re-sets their parents.

Container|null
_isCloning()

Is container cloning now?

Details

at line 37
IContainer addComponent(IComponent $component, string|null $name, string|null $insertBefore = null)

Adds a child component to the container.

Parameters

IComponent $component
string|null $name
string|null $insertBefore

Return Value

IContainer

Exceptions

InvalidStateException

at line 96
void removeComponent(IComponent $component)

Removes a child component from the container.

Parameters

IComponent $component

Return Value

void

at line 113
final IComponent|null getComponent(string $name, bool $throw = true)

Retrieves a child component by name or creates it if it doesn't exist.

Parameters

string $name
bool $throw

throw exception if component doesn't exist?

Return Value

IComponent|null

at line 158
protected IComponent|null createComponent(string $name)

Creates a new component. Delegates creation to createComponent method if it exists.

Parameters

string $name

Return Value

IComponent|null

at line 184
final iterable getComponents()

Returns all immediate child components.

Return Value

iterable

at line 206
final array getComponentTree()

Retrieves the entire hierarchy of components, including all nested child components (depth-first).

Return Value

array

at line 224
protected void validateChildComponent(IComponent $child)

Validates a child component before it's added to the container.

Descendant classes can override this to implement custom validation logic.

Parameters

IComponent $child

Return Value

void

Exceptions

InvalidStateException

at line 235
__clone()

Handles object cloning. Clones all child components and re-sets their parents.

at line 256
final Container|null _isCloning()

internal  
 

Is container cloning now?

Return Value

Container|null