abstract class Presenter extends Control implements IPresenter

Presenter object represents a webpage instance. It executes all the logic for the request.

Constants

PHASE_STARTUP

PHASE_SIGNAL

PHASE_RENDER

PHASE_SHUTDOWN

INVALID_LINK_SILENT

INVALID_LINK_WARNING

INVALID_LINK_EXCEPTION

SIGNAL_KEY

ACTION_KEY

FLASH_KEY

Properties

static string $defaultAction
static int $invalidLinkMode
array $onShutdown
bool $oldLayoutMode
bool $oldModuleMode
bool $autoCanonicalize
bool $absoluteUrls
string $view
string $layout
PresenterRequest read-only $request
int read-only $phase
array read-only $signal
string read-only $action
mixed read-only $payload
Application read-only $application

Methods

getRequest()

No description

Presenter|null
getPresenter($need = TRUE)

Returns self.

string
getUniqueId()

Returns a name that uniquely identifies component.

run(PresenterRequest $request)

No description

int
getPhase()

Returns current presenter life cycle phase.

void
startup()

No description

void
beforeRender()

Common render method.

void
afterRender()

Common render method.

void
shutdown($response)

No description

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

array
formatLayoutTemplateFiles($presenter, $layout)

Formats layout template file names.

array
formatTemplateFiles($presenter, $view)

Formats view template file names.

static string
formatActionMethod($action)

Formats action method name.

static string
formatRenderMethod($view)

Formats render view method name.

renderTemplate() deprecated

No description

getPayload()

No description

bool
isAjax()

Is AJAX request?

void
sendPayload()

Sends AJAX payload to the output.

getAjaxDriver() deprecated

No description

void
forward($destination, $args = array())

Forward to another presenter or action.

void
redirectUri($uri, $code = NULL)

Redirect to another URL and ends presenter execution.

string
backlink()

Link to myself.

getLastCreatedRequest()

Returns the last created PresenterRequest.

bool
getLastCreatedRequestFlag($flag)

Returns the last created PresenterRequest flag.

void
terminate(IPresenterResponse $response = NULL)

Correctly terminates presenter.

void
canonicalize()

Conditional redirect to canonicalized URI.

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

Attempts to cache the sent entity by its last modification date

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

PresenterRequest/URL factory.

string
handleInvalidLink($e)

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

static array
getPersistentComponents()

Returns array of persistent components.

void
saveGlobalState()

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

array
popGlobalParams($id)

Pops parameters for specified component.

bool
hasFlashSession()

Checks if a flash session namespace exists.

SessionNamespace
getFlashSession()

Returns session namespace provided to pass temporary data between redirects.

IHttpRequest
getHttpRequest()

No description

IHttpResponse
getHttpResponse()

No description

getApplication()

No description

Session
getSession($namespace = NULL)

No description

User
getUser()

No description

Details

at line 143
final PresenterRequest getRequest()

No description

Return Value

PresenterRequest

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

Returns self.

Parameters

$need

Return Value

Presenter|null

at line 165
final string getUniqueId()

Returns a name that uniquely identifies component.

Return Value

string

at line 180
IPresenterResponse run(PresenterRequest $request)

No description

Parameters

PresenterRequest $request

Return Value

IPresenterResponse

at line 272
final int getPhase()

Returns current presenter life cycle phase.

Return Value

int

at line 282
protected void startup()

No description

Return Value

void

at line 293
protected void beforeRender()

Common render method.

Return Value

void

at line 303
protected void afterRender()

Common render method.

Return Value

void

at line 313
protected void shutdown($response)

No description

Parameters

$response

Return Value

void

at line 327
void processSignal()

No description

Return Value

void

Exceptions

BadSignalException

at line 354
final array|null getSignal()

Returns pair signal receiver and name.

Return Value

array|null

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

Checks if the signal receiver is the given one.

Parameters

$component
$signal

Return Value

bool

at line 398
final string getAction($fullyQualified = FALSE)

Returns current action name.

Parameters

$fullyQualified

Return Value

string

at line 410
void changeAction($action)

Changes current action. Only alphanumeric characters are allowed.

Parameters

$action

Return Value

void

at line 427
final string getView()

Returns current view.

Return Value

string

at line 439
Presenter setView($view)

Changes current view. Any name is allowed.

Parameters

$view

Return Value

Presenter

provides a fluent interface

at line 451
final string|false getLayout()

Returns current layout name.

Return Value

string|false

at line 463
Presenter setLayout($layout)

Changes or disables layout.

Parameters

$layout

Return Value

Presenter

provides a fluent interface

at line 476
void sendTemplate()

No description

Return Value

void

Exceptions

BadRequestException
AbortException

at line 531
array formatLayoutTemplateFiles($presenter, $layout)

Formats layout template file names.

Parameters

$presenter
$layout

Return Value

array

at line 575
array formatTemplateFiles($presenter, $view)

Formats view template file names.

Parameters

$presenter
$view

Return Value

array

at line 611
static protected string formatActionMethod($action)

Formats action method name.

Parameters

$action

Return Value

string

at line 623
static protected string formatRenderMethod($view)

Formats render view method name.

Parameters

$view

Return Value

string

at line 633
protected renderTemplate() deprecated

deprecated

No description

at line 647
final stdClass getPayload()

No description

Return Value

stdClass

at line 658
bool isAjax()

Is AJAX request?

Return Value

bool

at line 673
protected void sendPayload()

Sends AJAX payload to the output.

Return Value

void

Exceptions

AbortException

at line 683
getAjaxDriver() deprecated

deprecated

No description

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

Forward to another presenter or action.

Parameters

$destination
$args

Return Value

void

Exceptions

AbortException

at line 724
void redirectUri($uri, $code = NULL)

Redirect to another URL and ends presenter execution.

Parameters

$uri
$code

Return Value

void

Exceptions

AbortException

Link to myself.

Return Value

string

at line 753
PresenterRequest getLastCreatedRequest()

Returns the last created PresenterRequest.

Return Value

PresenterRequest

at line 765
bool getLastCreatedRequestFlag($flag)

Returns the last created PresenterRequest flag.

Parameters

$flag

Return Value

bool

at line 778
void terminate(IPresenterResponse $response = NULL)

Correctly terminates presenter.

Parameters

IPresenterResponse $response

Return Value

void

Exceptions

AbortException

at line 791
void canonicalize()

Conditional redirect to canonicalized URI.

Return Value

void

Exceptions

AbortException

at line 811
int lastModified($lastModified, $etag = NULL, $expire = NULL)

Attempts to cache the sent entity by its last modification date

Parameters

$lastModified
$etag
$expire

Return Value

int

date of the client's cache version, if available

Exceptions

AbortException

at line 884
final protected string createRequest($component, $destination, array $args, $mode)

internal  
 

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

$e

Return Value

string

Exceptions

InvalidLinkException

at line 1134
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 1218
protected void saveGlobalState()

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

Return Value

void

at line 1286
final array popGlobalParams($id)

Pops parameters for specified component.

Parameters

$id

Return Value

array

at line 1308
bool hasFlashSession()

Checks if a flash session namespace exists.

Return Value

bool

at line 1320
SessionNamespace getFlashSession()

Returns session namespace provided to pass temporary data between redirects.

Return Value

SessionNamespace

at line 1337
protected IHttpRequest getHttpRequest()

No description

Return Value

IHttpRequest

at line 1347
protected IHttpResponse getHttpResponse()

No description

Return Value

IHttpResponse

at line 1357
Application getApplication()

No description

Return Value

Application

at line 1367
protected Session getSession($namespace = NULL)

No description

Parameters

$namespace

Return Value

Session

at line 1377
protected User getUser()

No description

Return Value

User