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

internal SIGNAL_KEY

internal ACTION_KEY

internal FLASH_KEY

internal DEFAULT_ACTION

Properties

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

Methods

__construct()

No description

getRequest()

No description

Presenter|null
getPresenter($need = 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|false
getLayout()

Returns current layout name.

setLayout($layout)

Changes or disables layout.

void
sendTemplate()

No description

string
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 = array())

Forward to another presenter or action.

void
redirectUrl($url, $code = NULL)

Redirect to another URL and ends presenter execution.

void
error($message = NULL, $code = Http\IResponse::S404_NOT_FOUND)

Throws HTTP error.

string
backlink() deprecated

Link to myself.

getLastCreatedRequest()

Returns the last created Request.

bool
getLastCreatedRequestFlag($flag)

Returns the last created Request flag.

void
canonicalize()

Conditional redirect to canonicalized URI.

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

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

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

Request/URL factory.

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
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

SystemContainer|Container
getContext() deprecated

Gets the context.

getService($name) deprecated

No description

IRequest
getHttpRequest()

No description

IResponse
getHttpResponse()

No description

Session|SessionSection
getSession($namespace = NULL)

No description

User
getUser()

No description

Details

at line 126
__construct()

No description

at line 135
Request getRequest()

No description

Return Value

Request

at line 145
Presenter|null getPresenter($need = TRUE)

Returns self.

Parameters

$need

Return Value

Presenter|null

at line 155
string getUniqueId()

Returns a name that uniquely identifies component.

Return Value

string

at line 167
IResponse run(Request $request)

No description

Parameters

Request $request

Return Value

IResponse

at line 253
protected void startup()

No description

Return Value

void

at line 263
protected void beforeRender()

Common render method.

Return Value

void

at line 272
protected void afterRender()

Common render method.

Return Value

void

at line 281
protected void shutdown($response)

No description

Parameters

$response

Return Value

void

at line 290
void checkRequirements($element)

Checks authorization.

Parameters

$element

Return Value

void

at line 306
void processSignal()

No description

Return Value

void

Exceptions

BadSignalException

at line 333
array|null getSignal()

Returns pair signal receiver and name.

Return Value

array|null

at line 345
bool isSignalReceiver($component, $signal = NULL)

Checks if the signal receiver is the given one.

Parameters

$component
$signal

Return Value

bool

at line 374
string getAction($fullyQualified = FALSE)

Returns current action name.

Parameters

$fullyQualified

Return Value

string

at line 385
void changeAction($action)

Changes current action. Only alphanumeric characters are allowed.

Parameters

$action

Return Value

void

at line 401
string getView()

Returns current view.

Return Value

string

at line 412
Presenter setView($view)

Changes current view. Any name is allowed.

Parameters

$view

Return Value

Presenter

at line 423
string|false getLayout()

Returns current layout name.

Return Value

string|false

at line 434
Presenter setLayout($layout)

Changes or disables layout.

Parameters

$layout

Return Value

Presenter

at line 446
void sendTemplate()

No description

Return Value

void

Exceptions

BadRequestException
AbortException

at line 478
string findLayoutTemplateFile()

internal  
 

Finds layout template file name.

Return Value

string

at line 502
array formatLayoutTemplateFiles()

Formats layout template file names.

Return Value

array

at line 528
array formatTemplateFiles()

Formats view template file names.

Return Value

array

at line 548
static string formatActionMethod($action)

Formats action method name.

Parameters

$action

Return Value

string

at line 559
static string formatRenderMethod($view)

Formats render view method name.

Parameters

$view

Return Value

string

at line 568
protected ITemplate createTemplate()

No description

Return Value

ITemplate

at line 580
stdClass getPayload()

No description

Return Value

stdClass

at line 590
bool isAjax()

Is AJAX request?

Return Value

bool

at line 604
void sendPayload()

Sends AJAX payload to the output.

Return Value

void

Exceptions

AbortException

at line 616
void sendJson($data)

Sends JSON data to the output.

Parameters

$data

Return Value

void

Exceptions

AbortException

at line 630
void sendResponse(IResponse $response)

Sends response and terminates presenter.

Parameters

IResponse $response

Return Value

void

Exceptions

AbortException

at line 642
void terminate()

Correctly terminates presenter.

Return Value

void

Exceptions

AbortException

at line 659
void forward($destination, $args = array())

Forward to another presenter or action.

Parameters

$destination
$args

Return Value

void

Exceptions

AbortException

at line 677
void redirectUrl($url, $code = NULL)

Redirect to another URL and ends presenter execution.

Parameters

$url
$code

Return Value

void

Exceptions

AbortException

at line 699
void error($message = NULL, $code = Http\IResponse::S404_NOT_FOUND)

Throws HTTP error.

Parameters

$message
$code

Return Value

void

Exceptions

BadRequestException

deprecated

Link to myself.

Return Value

string

at line 721
Request getLastCreatedRequest()

internal  
 

Returns the last created Request.

Return Value

Request

at line 733
bool getLastCreatedRequestFlag($flag)

internal  
 

Returns the last created Request flag.

Parameters

$flag

Return Value

bool

at line 744
void canonicalize()

Conditional redirect to canonicalized URI.

Return Value

void

Exceptions

AbortException

at line 766
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 788
protected string createRequest($component, $destination, array $args, $mode)

internal  
 

Request/URL factory.

Parameters

$component
$destination
array $args
$mode

Return Value

string URL

Exceptions

InvalidLinkException

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

Parameters

InvalidLinkException $e

Return Value

string

Exceptions

InvalidLinkException

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

Stores current request to session.

Parameters

$expiration

Return Value

string key

at line 1112
void restoreRequest($key)

Restores request from session.

Parameters

$key

Return Value

void

at line 1136
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 1146
protected array getGlobalState($forClass = NULL)

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

Parameters

$forClass

Return Value

array

at line 1214
protected void saveGlobalState()

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

Return Value

void

at line 1283
array popGlobalParameters($id)

internal  
 

Pops parameters for specified component.

Parameters

$id

Return Value

array

at line 1303
bool hasFlashSession()

Checks if a flash session namespace exists.

Return Value

bool

at line 1314
SessionSection getFlashSession()

Returns session namespace provided to pass temporary data between redirects.

Return Value

SessionSection

at line 1326
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 1349
SystemContainer|Container getContext() deprecated

deprecated

Gets the context.

Return Value

SystemContainer|Container

at line 1361
final getService($name) deprecated

deprecated

No description

Parameters

$name

at line 1371
protected IRequest getHttpRequest()

No description

Return Value

IRequest

at line 1380
protected IResponse getHttpResponse()

No description

Return Value

IResponse

at line 1390
Session|SessionSection getSession($namespace = NULL)

No description

Parameters

$namespace

Return Value

Session|SessionSection

at line 1402
User getUser()

No description

Return Value

User

at line 1414
ITemplateFactory getTemplateFactory()

No description

Return Value

ITemplateFactory