abstract class Presenter extends Control implements IPresenter

Presenter component represents a webpage instance. It converts Request to IResponse.

Constants

INVALID_LINK_SILENT

bad link handling Presenter::$invalidLinkMode

INVALID_LINK_WARNING

bad link handling Presenter::$invalidLinkMode

INVALID_LINK_EXCEPTION

bad link handling Presenter::$invalidLinkMode

INVALID_LINK_TEXTUAL

bad link handling Presenter::$invalidLinkMode

internal SIGNAL_KEY

internal ACTION_KEY

internal FLASH_KEY

internal DEFAULT_ACTION

Properties

int $invalidLinkMode
callable[] $onStartup
callable[] $onShutdown
bool $autoCanonicalize
bool $absoluteUrls
string $view
string|bool $layout
Request read-only $request
string read-only $action
stdClass read-only $payload
Container read-only $context
Session read-only $session
User read-only $user

Methods

__construct()

No description

Request|null
getRequest()

No description

Presenter|null
getPresenter($throw = true)

Returns self.

string
getUniqueId()

Returns a name that uniquely identifies component.

run(Request $request)

No description

void
startup()

No description

void
beforeRender()

Common render method.

void
afterRender()

Common render method.

void
shutdown($response)

No description

void
checkRequirements($element)

Checks authorization.

void
processSignal()

No description

array|null
getSignal()

Returns pair signal receiver and name.

bool
isSignalReceiver($component, $signal = null)

Checks if the signal receiver is the given one.

string
getAction($fullyQualified = false)

Returns current action name.

void
changeAction($action)

Changes current action. Only alphanumeric characters are allowed.

string
getView()

Returns current view.

setView($view)

Changes current view. Any name is allowed.

string|bool
getLayout()

Returns current layout name.

setLayout($layout)

Changes or disables layout.

void
sendTemplate()

No description

string|null
findLayoutTemplateFile()

Finds layout template file name.

array
formatLayoutTemplateFiles()

Formats layout template file names.

array
formatTemplateFiles()

Formats view template file names.

static string
formatActionMethod($action)

Formats action method name.

static string
formatRenderMethod($view)

Formats render view method name.

createTemplate()

No description

getPayload()

No description

bool
isAjax()

Is AJAX request?

void
sendPayload()

Sends AJAX payload to the output.

void
sendJson($data)

Sends JSON data to the output.

void
sendResponse(IResponse $response)

Sends response and terminates presenter.

void
terminate()

Correctly terminates presenter.

void
forward($destination, $args = [])

Forward to another presenter or action.

void
redirectUrl($url, $httpCode = null)

Redirect to another URL and ends presenter execution.

string
backlink() deprecated

Link to myself.

Request|null
getLastCreatedRequest()

Returns the last created Request.

bool
getLastCreatedRequestFlag($flag)

Returns the last created Request flag.

void
canonicalize($destination = null, array $args = [])

Conditional redirect to canonicalized URI.

void
lastModified($lastModified, $etag = null, $expire = null)

Attempts to cache the sent entity by its last modification date.

string|null
createRequest($component, $destination, array $args, $mode)

Request/URL factory.

string
requestToUrl(Request $request, $relative = null)

Converts Request to URL.

static void
argsToParams($class, $method, $args, $supplemental = [], $missing = [])

Converts list of arguments to named parameters.

string
handleInvalidLink(InvalidLinkException $e)

Invalid link handler. Descendant can override this method to change default behaviour.

string
storeRequest($expiration = '+ 10 minutes')

Stores current request to session.

void
restoreRequest($key)

Restores request from session.

static array
getPersistentComponents()

Returns array of persistent components.

array
getGlobalState($forClass = null)

Saves state information for all subcomponents to $this->globalState.

void
saveState(array $params, ComponentReflection $reflection = null)

Saves state informations for next request.

void
saveGlobalState()

Permanently saves state information for all subcomponents to $this->globalState.

array
popGlobalParameters($id)

Pops parameters for specified component.

bool
hasFlashSession()

Checks if a flash session namespace exists.

SessionSection
getFlashSession()

Returns session namespace provided to pass temporary data between redirects.

injectPrimary(Container $context = null, IPresenterFactory $presenterFactory = null, IRouter $router = null, IRequest $httpRequest, IResponse $httpResponse, Session $session = null, User $user = null, ITemplateFactory $templateFactory = null)

No description

Container
getContext() deprecated

Gets the context.

IRequest
getHttpRequest()

No description

IResponse
getHttpResponse()

No description

Session|SessionSection
getSession($namespace = null)

No description

User
getUser()

No description

Details

at line 131
__construct()

No description

at line 140
Request|null getRequest()

No description

Return Value

Request|null

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

Returns self.

Parameters

$throw

Return Value

Presenter|null

at line 160
string getUniqueId()

Returns a name that uniquely identifies component.

Return Value

string

at line 172
IResponse run(Request $request)

No description

Parameters

Request $request

Return Value

IResponse

at line 262
protected void startup()

No description

Return Value

void

at line 272
protected void beforeRender()

Common render method.

Return Value

void

at line 281
protected void afterRender()

Common render method.

Return Value

void

at line 290
protected void shutdown($response)

No description

Parameters

$response

Return Value

void

at line 299
void checkRequirements($element)

Checks authorization.

Parameters

$element

Return Value

void

at line 315
void processSignal()

No description

Return Value

void

Exceptions

BadSignalException

at line 338
array|null getSignal()

Returns pair signal receiver and name.

Return Value

array|null

at line 350
bool isSignalReceiver($component, $signal = null)

Checks if the signal receiver is the given one.

Parameters

$component
$signal

Return Value

bool

at line 379
string getAction($fullyQualified = false)

Returns current action name.

Parameters

$fullyQualified

Return Value

string

at line 390
void changeAction($action)

Changes current action. Only alphanumeric characters are allowed.

Parameters

$action

Return Value

void

at line 406
string getView()

Returns current view.

Return Value

string

at line 417
Presenter setView($view)

Changes current view. Any name is allowed.

Parameters

$view

Return Value

Presenter

at line 428
string|bool getLayout()

Returns current layout name.

Return Value

string|bool

at line 439
Presenter setLayout($layout)

Changes or disables layout.

Parameters

$layout

Return Value

Presenter

at line 451
void sendTemplate()

No description

Return Value

void

Exceptions

BadRequestException
AbortException

at line 478
string|null findLayoutTemplateFile()

internal  
 

Finds layout template file name.

Return Value

string|null

at line 501
array formatLayoutTemplateFiles()

Formats layout template file names.

Return Value

array

at line 526
array formatTemplateFiles()

Formats view template file names.

Return Value

array

at line 543
static string formatActionMethod($action)

Formats action method name.

Parameters

$action

Return Value

string

at line 554
static string formatRenderMethod($view)

Formats render view method name.

Parameters

$view

Return Value

string

at line 563
protected ITemplate createTemplate()

No description

Return Value

ITemplate

at line 575
stdClass getPayload()

No description

Return Value

stdClass

at line 585
bool isAjax()

Is AJAX request?

Return Value

bool

at line 599
void sendPayload()

Sends AJAX payload to the output.

Return Value

void

Exceptions

AbortException

at line 611
void sendJson($data)

Sends JSON data to the output.

Parameters

$data

Return Value

void

Exceptions

AbortException

at line 625
void sendResponse(IResponse $response)

Sends response and terminates presenter.

Parameters

IResponse $response

Return Value

void

Exceptions

AbortException

at line 637
void terminate()

Correctly terminates presenter.

Return Value

void

Exceptions

AbortException

at line 650
void forward($destination, $args = [])

Forward to another presenter or action.

Parameters

$destination
$args

Return Value

void

Exceptions

AbortException

at line 669
void redirectUrl($url, $httpCode = null)

Redirect to another URL and ends presenter execution.

Parameters

$url
$httpCode

Return Value

void

Exceptions

AbortException

deprecated

Link to myself.

Return Value

string

at line 701
Request|null getLastCreatedRequest()

internal  
 

Returns the last created Request.

Return Value

Request|null

at line 713
bool getLastCreatedRequestFlag($flag)

internal  
 

Returns the last created Request flag.

Parameters

$flag

Return Value

bool

at line 725
void canonicalize($destination = null, array $args = [])

Conditional redirect to canonicalized URI.

Parameters

$destination
array $args

Return Value

void

Exceptions

AbortException

at line 754
void lastModified($lastModified, $etag = null, $expire = null)

Attempts to cache the sent entity by its last modification date.

Parameters

$lastModified
$etag
$expire

Return Value

void

Exceptions

AbortException

at line 776
protected string|null createRequest($component, $destination, array $args, $mode)

internal  
 

Request/URL factory.

Parameters

$component
$destination
array $args
$mode

Return Value

string|null URL

Exceptions

InvalidLinkException

at line 969
protected string requestToUrl(Request $request, $relative = null)

internal  
 

Converts Request to URL.

Parameters

Request $request
$relative

Return Value

string

at line 1009
static void argsToParams($class, $method, $args, $supplemental = [], $missing = [])

internal  
 

Converts list of arguments to named parameters.

Parameters

$class
$method
$args
$supplemental
$missing

Return Value

void

Exceptions

InvalidLinkException

Invalid link handler. Descendant can override this method to change default behaviour.

Parameters

InvalidLinkException $e

Return Value

string

Exceptions

InvalidLinkException

at line 1085
string storeRequest($expiration = '+ 10 minutes')

Stores current request to session.

Parameters

$expiration

Return Value

string key

at line 1103
void restoreRequest($key)

Restores request from session.

Parameters

$key

Return Value

void

at line 1127
static array getPersistentComponents()

Returns array of persistent components.

This default implementation detects components by class-level annotation @persistent(cmp1, cmp2).

Return Value

array

at line 1137
protected array getGlobalState($forClass = null)

Saves state information for all subcomponents to $this->globalState.

Parameters

$forClass

Return Value

array

at line 1207
void saveState(array $params, ComponentReflection $reflection = null)

Saves state informations for next request.

Parameters

array $params
ComponentReflection $reflection

Return Value

void

at line 1218
protected void saveGlobalState()

Permanently saves state information for all subcomponents to $this->globalState.

Return Value

void

at line 1289
array popGlobalParameters($id)

internal  
 

Pops parameters for specified component.

Parameters

$id

Return Value

array

at line 1321
bool hasFlashSession()

Checks if a flash session namespace exists.

Return Value

bool

at line 1333
SessionSection getFlashSession()

Returns session namespace provided to pass temporary data between redirects.

Return Value

SessionSection

at line 1346
injectPrimary(Container $context = null, IPresenterFactory $presenterFactory = null, IRouter $router = null, IRequest $httpRequest, IResponse $httpResponse, Session $session = null, User $user = null, ITemplateFactory $templateFactory = null)

No description

Parameters

Container $context
IPresenterFactory $presenterFactory
IRouter $router
IRequest $httpRequest
IResponse $httpResponse
Session $session
User $user
ITemplateFactory $templateFactory

at line 1369
Container getContext() deprecated

deprecated

Gets the context.

Return Value

Container

at line 1381
IRequest getHttpRequest()

No description

Return Value

IRequest

at line 1390
IResponse getHttpResponse()

No description

Return Value

IResponse

at line 1400
Session|SessionSection getSession($namespace = null)

No description

Parameters

$namespace

Return Value

Session|SessionSection

at line 1412
User getUser()

No description

Return Value

User

at line 1424
ITemplateFactory getTemplateFactory()

No description

Return Value

ITemplateFactory