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 36)
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.
void
changeLayout ($layout)
void
changeScene ($view)
void
changeView ($view)
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.
IAjaxDriver|NULL
Application
SesssionNamespace
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.
mixed
static array
Returns array of persistent components.
int
Returns current presenter life cycle phase.
Presenter
getPresenter ([$need = TRUE])
Returns self.
PresenterRequest
getRequest ([bool $clone = TRUE])
void
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], [int $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 = IHttpResponse::S303_POST_GET])
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 prepare method.
protected void
Common render method.
protected IAjaxDriver
protected static string
formatActionMethod (string $action)
Formats action method name.
protected static string
formatPrepareMethod (string $view)
Formats prepare view 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
shutdown (Exception $exception)
protected void
startup ()
Methods Inherited From Control
createTemplate(), flashMessage(), getSnippetId(), getTemplate(), invalidateControl(), isControlInvalid(), 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 54

special parameter key
string FLASH_KEY '_fid'

line 55

special parameter key
INVALID_LINK_EXCEPTION 3

line 49

bad link handling Presenter::$invalidLinkMode
INVALID_LINK_SILENT 1

line 47

bad link handling Presenter::$invalidLinkMode
INVALID_LINK_WARNING 2

line 48

bad link handling Presenter::$invalidLinkMode
int PHASE_PREPARE 2

line 40

life cycle phases Presenter::getPhase()
int PHASE_RENDER 4

line 42

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

line 43

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

line 41

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

line 39

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

line 53

special parameter key
Variable Summary
bool $absoluteUrls FALSE

line 80

use absolute Urls or paths?
bool $autoCanonicalize TRUE

line 77

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

line 59

static int $invalidLinkMode

line 62

bool $oldLayoutMode TRUE

line 68

(experimental)
array $onShutdown

line 65

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

Method Details

line 123

__construct

public Presenter __construct (PresenterRequest $request)

Input
PresenterRequest $request
Output
Presenter  

line 292

afterRender

protected void afterRender ()

Common render method.

Output
void  

line 272

beforePrepare

protected void beforePrepare ()

Common prepare method.

Output
void  

line 282

beforeRender

protected void beforeRender ()

Common render method.

Output
void  

line 804

canonicalize

public void canonicalize ()

Conditional redirect to canonicalized URI.

Output
void  
Throws
throws RedirectingException

line 399

changeAction

public void changeAction (string $action)

Changes current action. Only alphanumeric characters are allowed.

Input
string $action
Output
void  

line 494

changeLayout

public void changeLayout ($layout)

Input
$layout
Output
void  
Tags
Deprecated

line 483

changeScene

public void changeScene ($view)

Input
$view
Output
void  
Tags
Deprecated

line 461

changeView

public void changeView ($view)

Input
$view
Output
void  
Tags
Deprecated

line 699

createAjaxDriver

protected IAjaxDriver createAjaxDriver ()

Output
IAjaxDriver  

line 619

formatActionMethod

protected static string formatActionMethod (string $action)

Formats action method name.

Input
string $action
Output
string  

line 564

formatLayoutTemplateFiles

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

Formats layout template file names.

Input
string $presenter
string $layout
Output
array  

line 631

formatPrepareMethod

protected static string formatPrepareMethod (string $view)

Formats prepare view method name.

Input
string $view
Output
string  

line 643

formatRenderMethod

protected static string formatRenderMethod (string $view)

Formats render view method name.

Input
string $view
Output
string  

line 595

formatTemplateFiles

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

Formats view template file names.

Input
string $presenter
string $view
Output
array  

line 717

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 387

getAction

public string getAction ([$fullyQualified = FALSE])

Returns current action name.

Input
$fullyQualified
Output
string  

line 681

getAjaxDriver

public IAjaxDriver|NULL getAjaxDriver ()

Output
IAjaxDriver|NULL  

line 1363

getApplication

public Application getApplication ()

Output
Application  

line 1326

getFlashSession

public SesssionNamespace getFlashSession ()

Returns session namespace provided to pass temporary data between redirects.

Output
SesssionNamespace  

line 1343

getHttpRequest

protected IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 1353

getHttpResponse

protected IHttpResponse getHttpResponse ()

Output
IHttpResponse  

line 768

getLastCreatedRequest

public PresenterRequest getLastCreatedRequest ()

Returns the last created PresenterRequest.

Output
PresenterRequest  

line 780

getLastCreatedRequestFlag

public bool getLastCreatedRequestFlag (string $flag)

Returns the last created PresenterRequest flag.

Input
string $flag
Output
bool  

line 439

getLayout

public string|FALSE getLayout ()

Returns current layout name.

Output
string|FALSE  

line 657

getPayload

public mixed getPayload ()

Output
mixed  

line 1145

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 252

getPhase

public int getPhase ()

Returns current presenter life cycle phase.

Output
int  

line 146

getPresenter

public Presenter getPresenter ([$need = TRUE])

Returns self.

Input
$need
Output
Presenter  

line 135

getRequest

public PresenterRequest getRequest ([bool $clone = TRUE])

Input
bool $clone
Output
PresenterRequest  

line 472

getScene

public void getScene ()

Output
void  
Tags
Deprecated

line 343

getSignal

public array|NULL getSignal ()

Returns pair signal receiver and name.

Output
array|NULL  

line 157

getUniqueId

public string getUniqueId ()

Returns a name that uniquely identifies component.

Output
string  

line 416

getView

public string getView ()

Returns current view.

Output
string  

line 1314

hasFlashSession

public bool hasFlashSession ()

Checks if a flash session namespace exists.

Output
bool  

line 668

isAjax

public bool isAjax ()

Is AJAX request?

Output
bool  

line 356

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 824

lastModified

public int lastModified (int $lastModified, [string $etag = NULL], [int $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
int $expire optional expiration time
Output
int date of the client's cache version, if available
Throws
throws TerminateException

line 1292

popGlobalParams

public array popGlobalParams (string $id)

Pops parameters for specified component.

Input
string $id component id
Output
array  

line 316

processSignal

public void processSignal ()

Output
void  
Throws
throws BadSignalException

line 740

redirectUri

public void redirectUri (string $uri, [int $code = IHttpResponse::S303_POST_GET])

Redirect to another URL and ends presenter execution.

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

line 506

renderTemplate

public void renderTemplate ()

Output
void  
Throws
throws BadRequestException if no template found

line 172

run

public void run ()

Implementation of:

Output
void  
Throws
throws AbortException

line 1229

saveGlobalState

protected void saveGlobalState ()

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

Output
void  

line 451

setLayout

public void setLayout (string|FALSE $layout)

Changes or disables layout.

Input
string|FALSE $layout
Output
void  

line 428

setView

public void setView (string $view)

Changes current view. Any name is allowed.

Input
string $view
Output
void  

line 302

shutdown

protected void shutdown (Exception $exception)

Input
Exception $exception optional catched exception
Output
void  

line 262

startup

protected void startup ()

Output
void  

line 792

terminate

public void terminate ()

Correctly terminates presenter.

Output
void  
Throws
throws TerminateException