Class Presenter (namespace Nette\Application)


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

Implements interfaces:

Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Abstract:
Located: in /Application/Presenter.php (line 44)
Public Method Summary
Presenter
string
Link to myself.
void
Conditional redirect to canonicalized URI.
void
changeAction (string $action)
Changes current action. Only alphanumeric characters are allowed.
array
formatLayoutTemplateFiles (string $presenter, string $layout)
Formats layout template file names.
array
formatTemplateFiles (string $presenter, string $view)
Formats view template file names.
void
forward (string|PresenterRequest $destination, [array|mixed $args = array()])
Forward to another presenter or action.
string
getAction ([$fullyQualified = FALSE])
Returns current action name.
void
Application
SessionNamespace
Returns session namespace provided to pass temporary data between redirects.
PresenterRequest
Returns the last created PresenterRequest.
bool
getLastCreatedRequestFlag (string $flag)
Returns the last created PresenterRequest flag.
string|FALSE
Returns current layout name.
stdClass
static array
Returns array of persistent components.
int
Returns current presenter life cycle phase.
Presenter
getPresenter ([$need = TRUE])
Returns self.
PresenterRequest
array|NULL
Returns pair signal receiver and name.
string
Returns a name that uniquely identifies component.
string
getView ()
Returns current view.
bool
Checks if a flash session namespace exists.
bool
isAjax ()
Is AJAX request?
bool
isSignalReceiver (mixed $component, [string $signal = NULL])
Checks if the signal receiver is the given one.
int
lastModified (int $lastModified, [string $etag = NULL], [mixed $expire = NULL])
Attempts to cache the sent entity by its last modification date
array
popGlobalParams (string $id)
Pops parameters for specified component.
void
void
redirectUri (string $uri, [int $code = NULL])
Redirect to another URL and ends presenter execution.
void
void
run ()
void
setLayout (string|FALSE $layout)
Changes or disables layout.
void
setView (string $view)
Changes current view. Any name is allowed.
void
Correctly terminates presenter.
Protected Method Summary
protected void
Common render method.
protected void
Common render method.
protected static string
formatActionMethod (string $action)
Formats action method name.
protected static string
formatRenderMethod (string $view)
Formats render view method name.
protected IHttpRequest
protected IHttpResponse
protected string
Invalid link handler. Descendant can override this method to change default behaviour.
protected void
Permanently saves state information for all subcomponents to $this->globalState.
protected void
Sends AJAX payload to the output.
protected void
shutdown (Exception $exception)
protected void
startup ()
Methods Inherited From Control
createComponent(), createTemplate(), flashMessage(), getSnippetId(), getTemplate(), getWidget(), invalidateControl(), isControlInvalid(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), templatePrepareFilters(), validateControl()
Methods Inherited From PresenterComponent
__construct(), ajaxLink(), attached(), formatSignalMethod(), getParam(), getParamId(), getPersistentParams(), getPresenter(), getUniqueId(), lazyLink(), link(), loadState(), redirect(), saveState(), signalReceived(), tryCall()
Methods Inherited From ComponentContainer
addComponent(), createComponent(), getComponent(), getComponents(), removeComponent(), validateChildComponent(), __clone()
Methods Inherited From Component
__construct(), attached(), detached(), getName(), getParent(), getService(), getServiceLocator(), lookup(), lookupPath(), monitor(), setParent(), setServiceLocator(), validateParent(), __clone(), __wakeup()
Methods Inherited From Object
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()
Constant Summary
string ACTION_KEY 'action'

line 61

special parameter key
string FLASH_KEY '_fid'

line 62

special parameter key
INVALID_LINK_EXCEPTION 3

line 56

bad link handling Presenter::$invalidLinkMode
INVALID_LINK_SILENT 1

line 54

bad link handling Presenter::$invalidLinkMode
INVALID_LINK_WARNING 2

line 55

bad link handling Presenter::$invalidLinkMode
int PHASE_RENDER 4

line 49

life cycle phases Presenter::getPhase()
int PHASE_SHUTDOWN 5

line 50

life cycle phases Presenter::getPhase()
int PHASE_SIGNAL 3

line 48

life cycle phases Presenter::getPhase()
int PHASE_STARTUP 1

line 47

life cycle phases Presenter::getPhase()
string SIGNAL_KEY 'do'

line 60

special parameter key
Variable Summary
bool $absoluteUrls FALSE

line 87

use absolute Urls or paths?
bool $autoCanonicalize TRUE

line 84

automatically call canonicalize()
static string $defaultAction 'default'

line 66

static int $invalidLinkMode

line 69

bool $oldLayoutMode TRUE

line 75

(experimental)
array $onShutdown

line 72

of function(Presenter $sender, \Exception $exception = NULL); Occurs when the presenter is shutting down

Method Details

line 133

__construct

public Presenter __construct (PresenterRequest $request)

Input
PresenterRequest $request
Output
Presenter  

line 295

afterRender

protected void afterRender ()

Common render method.

Output
void  

line 285

beforeRender

protected void beforeRender ()

Common render method.

Output
void  

line 748

canonicalize

public void canonicalize ()

Conditional redirect to canonicalized URI.

Output
void  
Throws
throws RedirectingException

line 402

changeAction

public void changeAction (string $action)

Changes current action. Only alphanumeric characters are allowed.

Input
string $action
Output
void  

line 572

formatActionMethod

protected static string formatActionMethod (string $action)

Formats action method name.

Input
string $action
Output
string  

line 517

formatLayoutTemplateFiles

public array formatLayoutTemplateFiles (string $presenter, string $layout)

Formats layout template file names.

Input
string $presenter
string $layout
Output
array  

line 584

formatRenderMethod

protected static string formatRenderMethod (string $view)

Formats render view method name.

Input
string $view
Output
string  

line 548

formatTemplateFiles

public array formatTemplateFiles (string $presenter, string $view)

Formats view template file names.

Input
string $presenter
string $view
Output
array  

line 658

forward

public void forward (string|PresenterRequest $destination, [array|mixed $args = array()])

Forward to another presenter or action.

Input
string|PresenterRequest $destination
array|mixed $args
Output
void  
Throws
throws ForwardingException

line 390

getAction

public string getAction ([$fullyQualified = FALSE])

Returns current action name.

Input
$fullyQualified
Output
string  

line 640

getAjaxDriver

public void getAjaxDriver ()

Output
void  
Tags
Deprecated

line 1314

getApplication

public Application getApplication ()

Output
Application  

line 1277

getFlashSession

public SessionNamespace getFlashSession ()

Returns session namespace provided to pass temporary data between redirects.

Output
SessionNamespace  

line 1294

getHttpRequest

protected IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 1304

getHttpResponse

protected IHttpResponse getHttpResponse ()

Output
IHttpResponse  

line 712

getLastCreatedRequest

public PresenterRequest getLastCreatedRequest ()

Returns the last created PresenterRequest.

Output
PresenterRequest  

line 724

getLastCreatedRequestFlag

public bool getLastCreatedRequestFlag (string $flag)

Returns the last created PresenterRequest flag.

Input
string $flag
Output
bool  

line 442

getLayout

public string|FALSE getLayout ()

Returns current layout name.

Output
string|FALSE  

line 598

getPayload

public stdClass getPayload ()

Output
stdClass  

line 1091

getPersistentComponents

public static array getPersistentComponents ()

Returns array of persistent components.

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

Output
array  

line 264

getPhase

public int getPhase ()

Returns current presenter life cycle phase.

Output
int  

line 156

getPresenter

public Presenter getPresenter ([$need = TRUE])

Returns self.

Input
$need
Output
Presenter  

line 145

getRequest

public PresenterRequest getRequest ()

Output
PresenterRequest  

line 346

getSignal

public array|NULL getSignal ()

Returns pair signal receiver and name.

Output
array|NULL  

line 167

getUniqueId

public string getUniqueId ()

Returns a name that uniquely identifies component.

Output
string  

line 419

getView

public string getView ()

Returns current view.

Output
string  

line 1265

hasFlashSession

public bool hasFlashSession ()

Checks if a flash session namespace exists.

Output
bool  

line 609

isAjax

public bool isAjax ()

Is AJAX request?

Output
bool  

line 359

isSignalReceiver

public bool isSignalReceiver (mixed $component, [string $signal = NULL])

Checks if the signal receiver is the given one.

Input
mixed $component component or its id
string $signal signal name (optional)
Output
bool  

line 768

lastModified

public int lastModified (int $lastModified, [string $etag = NULL], [mixed $expire = NULL])

Attempts to cache the sent entity by its last modification date

Input
int $lastModified last modified time as unix timestamp
string $etag strong entity tag validator
mixed $expire optional expiration time
Output
int date of the client's cache version, if available
Throws
throws TerminateException

line 1243

popGlobalParams

public array popGlobalParams (string $id)

Pops parameters for specified component.

Input
string $id component id
Output
array  

line 319

processSignal

public void processSignal ()

Output
void  
Throws
throws BadSignalException

line 681

redirectUri

public void redirectUri (string $uri, [int $code = NULL])

Redirect to another URL and ends presenter execution.

Input
string $uri
int $code HTTP error code
Output
void  
Throws
throws RedirectingException

line 465

renderTemplate

public void renderTemplate ()

Output
void  
Throws
throws BadRequestException if no template found

line 182

run

public void run ()

Implementation of:

Output
void  
Throws
throws AbortException

line 1175

saveGlobalState

protected void saveGlobalState ()

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

Output
void  

line 623

sendPayload

protected void sendPayload ()

Sends AJAX payload to the output.

Output
void  

line 454

setLayout

public void setLayout (string|FALSE $layout)

Changes or disables layout.

Input
string|FALSE $layout
Output
void  

line 431

setView

public void setView (string $view)

Changes current view. Any name is allowed.

Input
string $view
Output
void  

line 305

shutdown

protected void shutdown (Exception $exception)

Input
Exception $exception optional catched exception
Output
void  

line 274

startup

protected void startup ()

Output
void  

line 736

terminate

public void terminate ()

Correctly terminates presenter.

Output
void  
Throws
throws TerminateException