abstract class Component extends Container implements SignalReceiver, StatePersistent, ArrayAccess

Component is the base class for all Presenter components.

Components are persistent objects located on a presenter. They have ability to own other child components, and interact with user. Components have properties for storing their status, and responds to user command.

Properties

$onAnchor
protected array<string,mixed> $params

Methods

Presenter|null
getPresenter(bool $throw = true)

Returns the presenter where this component belongs to. Throws if not attached.

Presenter|null
getPresenterIfExists() deprecated

Returns the presenter where this component belongs to, or null if not attached.

bool
hasPresenter() deprecated

No description

string
getUniqueId()

Returns a fully-qualified name that uniquely identifies the component within the presenter hierarchy.

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

No description

IComponent|null
createComponent(string $name)

No description

void
validateParent(IContainer $parent)

No description

bool
tryCall(string $method, array $params)

Calls public method if exists.

void
checkRequirements(ReflectionClass|ReflectionMethod $element)

Descendant can override this method to check for permissions.

getReflection()

Access to reflection.

void
loadState(array $params)

Loads state information.

void
saveState(array $params)

Saves state information for next request.

void
saveStatePartial(array $params, ComponentReflection $reflection)

No description

mixed
getParameter(string $name)

Returns component param.

array
getParameters()

Returns component parameters.

string
getParameterId(string $name)

Returns a fully-qualified name that uniquely identifies the parameter.

void
signalReceived(string $signal)

Calls signal handler method.

static string
formatSignalMethod(string $signal)

Formats signal handler method name -> case sensitivity doesn't matter.

string
link(string $destination, mixed ...$args)

Generates URL to presenter, action or signal.

lazyLink(string $destination, mixed ...$args)

Returns destination as Link object.

bool
isLinkCurrent(string|null $destination = null, mixed ...$args)

Determines whether it links to the current page.

never
redirect(string $destination, mixed ...$args)

Redirect to another presenter, action or signal.

never
redirectPermanent(string $destination, mixed ...$args)

Permanently redirects to presenter, action or signal.

never
error(string $message = '', int $httpCode = Nette\Http\IResponse::S404_NotFound)

Throws HTTP error.

Details

at line 41
Presenter|null getPresenter(bool $throw = true)

Returns the presenter where this component belongs to. Throws if not attached.

Parameters

bool $throw

Return Value

Presenter|null

at line 51
Presenter|null getPresenterIfExists() deprecated

deprecated

Returns the presenter where this component belongs to, or null if not attached.

Return Value

Presenter|null

at line 58
bool hasPresenter() deprecated

deprecated

No description

Return Value

bool

at line 68
string getUniqueId()

Returns a fully-qualified name that uniquely identifies the component within the presenter hierarchy.

Return Value

string

at line 74
Component addComponent(IComponent $component, string|null $name, string|null $insertBefore = null)

No description

Parameters

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

Return Value

Component

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

No description

Parameters

string $name

Return Value

IComponent|null

at line 99
protected void validateParent(IContainer $parent)

No description

Parameters

IContainer $parent

Return Value

void

at line 113
protected bool tryCall(string $method, array $params)

Calls public method if exists.

Parameters

string $method
array $params

Return Value

bool

at line 141
void checkRequirements(ReflectionClass|ReflectionMethod $element)

Descendant can override this method to check for permissions.

It is called with the presenter class and the render(), action(), and handle*() methods.

Parameters

ReflectionClass|ReflectionMethod $element

Return Value

void

at line 149
static ComponentReflection getReflection()

Access to reflection.

Return Value

ComponentReflection

at line 162
void loadState(array $params)

Loads state information.

Parameters

array $params

Return Value

void

at line 191
void saveState(array $params)

Saves state information for next request.

Parameters

array $params

Return Value

void

at line 201
void saveStatePartial(array $params, ComponentReflection $reflection)

internal  used by presenter
 

No description

Parameters

array $params
ComponentReflection $reflection

Return Value

void

at line 240
final mixed getParameter(string $name)

Returns component param.

Parameters

string $name

Return Value

mixed

at line 254
final array getParameters()

Returns component parameters.

Return Value

array

at line 263
final string getParameterId(string $name)

Returns a fully-qualified name that uniquely identifies the parameter.

Parameters

string $name

Return Value

string

at line 277
void signalReceived(string $signal)

Calls signal handler method.

Parameters

string $signal

Return Value

void

Exceptions

BadSignalException

at line 289
static string formatSignalMethod(string $signal)

Formats signal handler method name -> case sensitivity doesn't matter.

Parameters

string $signal

Return Value

string

Generates URL to presenter, action or signal.

Parameters

string $destination

in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"

mixed ...$args

Return Value

string

Exceptions

InvalidLinkException

Returns destination as Link object.

Parameters

string $destination

in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"

mixed ...$args

Return Value

Link

at line 338
bool isLinkCurrent(string|null $destination = null, mixed ...$args)

Determines whether it links to the current page.

Parameters

string|null $destination

in format "[[[module:]presenter:]action | signal! | this]"

mixed ...$args

Return Value

bool

Exceptions

InvalidLinkException

at line 357
never redirect(string $destination, mixed ...$args)

Redirect to another presenter, action or signal.

Parameters

string $destination

in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"

mixed ...$args

Return Value

never

Exceptions

AbortException

at line 374
never redirectPermanent(string $destination, mixed ...$args)

Permanently redirects to presenter, action or signal.

Parameters

string $destination

in format "[//] [[[module:]presenter:]action | signal! | this] [#fragment]"

mixed ...$args

Return Value

never

Exceptions

AbortException

at line 392
never error(string $message = '', int $httpCode = Nette\Http\IResponse::S404_NotFound)

Throws HTTP error.

Parameters

string $message
int $httpCode

Return Value

never

Exceptions

BadRequestException

Traits

SmartObject
ArrayAccess