abstract class Component extends Container implements ISignalReceiver, IStatePersistent, 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

callable[] $onAnchor
protected array $params
Presenter read-only $presenter
bool read-only $linkCurrent

Methods

Presenter|null
getPresenter($throw = true)

Returns the presenter where this component belongs to.

string
getUniqueId()

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

void
attached($presenter)

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
validateParent(IContainer $parent)

No description

bool
tryCall($method, array $params)

Calls public method if exists.

void
checkRequirements($element)

Checks for requirements such as authorization.

getReflection()

Access to reflection.

void
loadState(array $params)

Loads state informations.

void
saveState(array $params)

Saves state informations for next request.

mixed
getParameter($name, $default = null)

Returns component param.

array
getParameters()

Returns component parameters.

string
getParameterId($name)

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

getParam($name = null, $default = null) deprecated

No description

static array
getPersistentParams()

Returns array of classes persistent parameters. They have public visibility and are non-static.

void
signalReceived($signal)

Calls signal handler method.

static string
formatSignalMethod($signal)

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

string
link($destination, $args = [])

Generates URL to presenter, action or signal.

lazyLink($destination, $args = [])

Returns destination as Link object.

bool
isLinkCurrent($destination = null, $args = [])

Determines whether it links to the current page.

void
redirect($code, $destination = null, $args = [])

Redirect to another presenter, action or signal.

void
redirectPermanent($destination = null, $args = [])

Permanently redirects to presenter, action or signal.

void
error($message = null, $httpCode = Nette\Http\IResponse::S404_NOT_FOUND)

Throws HTTP error.

void
offsetSet($name, $component)

Adds the component to the container.

IComponent
offsetGet($name)

Returns component specified by name. Throws exception if component doesn't exist.

bool
offsetExists($name)

Does component specified by name exists?

void
offsetUnset($name)

Removes component from the container.

Details

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

Returns the presenter where this component belongs to.

Parameters

$throw

Return Value

Presenter|null

at line 48
string getUniqueId()

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

Return Value

string

at line 60
protected void attached($presenter)

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

$presenter

Return Value

void

at line 72
protected void validateParent(IContainer $parent)

No description

Parameters

IContainer $parent

Return Value

void

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

Calls public method if exists.

Parameters

$method
array $params

Return Value

bool

does method exist?

at line 104
void checkRequirements($element)

Checks for requirements such as authorization.

Parameters

$element

Return Value

void

at line 113
static ComponentReflection getReflection()

Access to reflection.

Return Value

ComponentReflection

at line 127
void loadState(array $params)

Loads state informations.

Parameters

array $params

Return Value

void

at line 155
void saveState(array $params)

Saves state informations for next request.

Parameters

array $params

Return Value

void

at line 167
mixed getParameter($name, $default = null)

Returns component param.

Parameters

$name
$default

Return Value

mixed

at line 182
array getParameters()

Returns component parameters.

Return Value

array

at line 193
string getParameterId($name)

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

Parameters

$name

Return Value

string

at line 201
getParam($name = null, $default = null) deprecated

deprecated

No description

Parameters

$name
$default

at line 213
static array getPersistentParams()

Returns array of classes persistent parameters. They have public visibility and are non-static.

This default implementation detects persistent parameters by annotation @persistent.

Return Value

array

at line 235
void signalReceived($signal)

Calls signal handler method.

Parameters

$signal

Return Value

void

Exceptions

BadSignalException

at line 249
static string formatSignalMethod($signal)

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

Parameters

$signal

Return Value

string

Generates URL to presenter, action or signal.

Parameters

$destination
$args

Return Value

string

Exceptions

InvalidLinkException

Returns destination as Link object.

Parameters

$destination
$args

Return Value

Link

at line 297
bool isLinkCurrent($destination = null, $args = [])

Determines whether it links to the current page.

Parameters

$destination
$args

Return Value

bool

Exceptions

InvalidLinkException

at line 315
void redirect($code, $destination = null, $args = [])

Redirect to another presenter, action or signal.

Parameters

$code
$destination
$args

Return Value

void

Exceptions

AbortException

at line 338
void redirectPermanent($destination = null, $args = [])

Permanently redirects to presenter, action or signal.

Parameters

$destination
$args

Return Value

void

Exceptions

AbortException

at line 356
void error($message = null, $httpCode = Nette\Http\IResponse::S404_NOT_FOUND)

Throws HTTP error.

Parameters

$message
$httpCode

Return Value

void

Exceptions

BadRequestException

at line 371
void offsetSet($name, $component)

Adds the component to the container.

Parameters

$name
$component

Return Value

void

at line 383
IComponent offsetGet($name)

Returns component specified by name. Throws exception if component doesn't exist.

Parameters

$name

Return Value

IComponent

Exceptions

InvalidArgumentException

at line 394
bool offsetExists($name)

Does component specified by name exists?

Parameters

$name

Return Value

bool

at line 405
void offsetUnset($name)

Removes component from the container.

Parameters

$name

Return Value

void