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
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.
IPresenterResponse
run (PresenterRequest $request)
void
Presenter
setLayout (string|FALSE $layout)
Changes or disables layout.
Presenter
setView (string $view)
Changes current view. Any name is allowed.
void
terminate ([IPresenterResponse $response = NULL])
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 Session
getSession ([$namespace = NULL])
protected User
getUser ()
protected string
Invalid link handler. Descendant can override this method to change default behaviour.
protected void
protected void
Permanently saves state information for all subcomponents to $this->globalState.
protected void
Sends AJAX payload to the output.
protected void
protected void
startup ()
Methods Inherited From Control
createTemplate(), flashMessage(), getSnippetId(), getTemplate(), getWidget(), invalidateControl(), isControlInvalid(), templatePrepareFilters(), validateControl()
Methods Inherited From PresenterComponent
__construct(), ajaxLink(), attached(), formatSignalMethod(), getParam(), getParamId(), getPersistentParams(), getPresenter(), getUniqueId(), lazyLink(), link(), loadState(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), redirect(), saveState(), signalReceived(), tryCall()
Methods Inherited From ComponentContainer
addComponent(), createComponent(), getComponent(), getComponents(), removeComponent(), validateChildComponent(), __clone()
Methods Inherited From Component
__construct(), attached(), detached(), getName(), getParent(), lookup(), lookupPath(), monitor(), setParent(), unmonitor(), validateParent(), __clone(), __wakeup()
Methods Inherited From Object
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()
Constant Summary
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()
Variable Summary
bool $absoluteUrls FALSE

line 93

use absolute Urls or paths?
bool $autoCanonicalize TRUE

line 90

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

line 66

static int $invalidLinkMode

line 69

bool $oldLayoutMode TRUE

line 75

(experimental)
bool $oldModuleMode TRUE

line 78

(experimental)
array $onShutdown

line 72

of function(Presenter $sender, IPresenterResponse $response = NULL); Occurs when the presenter is shutting down

Method Details

line 299

afterRender

protected void afterRender ()

Common render method.

Output
void  

line 289

beforeRender

protected void beforeRender ()

Common render method.

Output
void  

line 787

canonicalize

public void canonicalize ()

Conditional redirect to canonicalized URI.

Output
void  
Throws
throws AbortException

line 406

changeAction

public void changeAction (string $action)

Changes current action. Only alphanumeric characters are allowed.

Input
string $action
Output
void  

line 607

formatActionMethod

protected static string formatActionMethod (string $action)

Formats action method name.

Input
string $action
Output
string  

line 527

formatLayoutTemplateFiles

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

Formats layout template file names.

Input
string $presenter
string $layout
Output
array  

line 619

formatRenderMethod

protected static string formatRenderMethod (string $view)

Formats render view method name.

Input
string $view
Output
string  

line 571

formatTemplateFiles

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

Formats view template file names.

Input
string $presenter
string $view
Output
array  

line 697

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 AbortException

line 394

getAction

public string getAction ([$fullyQualified = FALSE])

Returns current action name.

Input
$fullyQualified
Output
string  

line 679

getAjaxDriver

public void getAjaxDriver ()

Output
void  
Tags
Deprecated

line 1353

getApplication

public Application getApplication ()

Output
Application  

line 1316

getFlashSession

public SessionNamespace getFlashSession ()

Returns session namespace provided to pass temporary data between redirects.

Output
SessionNamespace  

line 1333

getHttpRequest

protected IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 1343

getHttpResponse

protected IHttpResponse getHttpResponse ()

Output
IHttpResponse  

line 749

getLastCreatedRequest

public PresenterRequest getLastCreatedRequest ()

Returns the last created PresenterRequest.

Output
PresenterRequest  

line 761

getLastCreatedRequestFlag

public bool getLastCreatedRequestFlag (string $flag)

Returns the last created PresenterRequest flag.

Input
string $flag
Output
bool  

line 447

getLayout

public string|FALSE getLayout ()

Returns current layout name.

Output
string|FALSE  

line 643

getPayload

public stdClass getPayload ()

Output
stdClass  

line 1130

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 268

getPhase

public int getPhase ()

Returns current presenter life cycle phase.

Output
int  

line 150

getPresenter

public Presenter getPresenter ([$need = TRUE])

Returns self.

Input
$need
Output
Presenter  

line 139

getRequest

public PresenterRequest getRequest ()

Output
PresenterRequest  

line 1363

getSession

protected Session getSession ([$namespace = NULL])

Input
$namespace
Output
Session  

line 350

getSignal

public array|NULL getSignal ()

Returns pair signal receiver and name.

Output
array|NULL  

line 161

getUniqueId

public string getUniqueId ()

Returns a name that uniquely identifies component.

Output
string  

line 1373

getUser

protected User getUser ()

Output
User  

line 423

getView

public string getView ()

Returns current view.

Output
string  

line 1304

hasFlashSession

public bool hasFlashSession ()

Checks if a flash session namespace exists.

Output
bool  

line 654

isAjax

public bool isAjax ()

Is AJAX request?

Output
bool  

line 363

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 807

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 AbortException

line 1282

popGlobalParams

public array popGlobalParams (string $id)

Pops parameters for specified component.

Input
string $id component id
Output
array  

line 323

processSignal

public void processSignal ()

Output
void  
Throws
throws BadSignalException

line 720

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 AbortException

line 629

renderTemplate

protected void renderTemplate ()

Output
void  
Tags
Deprecated

line 176

run

public IPresenterResponse run (PresenterRequest $request)

Implementation of:

Input
PresenterRequest $request
Output
IPresenterResponse  

line 1214

saveGlobalState

protected void saveGlobalState ()

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

Output
void  

line 669

sendPayload

protected void sendPayload ()

Sends AJAX payload to the output.

Output
void  
Throws
throws AbortException

line 472

sendTemplate

public void sendTemplate ()

Output
void  
Throws
throws AbortException
throws BadRequestException if no template found

line 459

setLayout

public Presenter setLayout (string|FALSE $layout)

Changes or disables layout.

Input
string|FALSE $layout
Output
Presenter provides a fluent interface

line 435

setView

public Presenter setView (string $view)

Changes current view. Any name is allowed.

Input
string $view
Output
Presenter provides a fluent interface

line 309

shutdown

protected void shutdown (IPresenterResponse $response)

Input
IPresenterResponse $response optional catched exception
Output
void  

line 278

startup

protected void startup ()

Output
void  

line 774

terminate

public void terminate ([IPresenterResponse $response = NULL])

Correctly terminates presenter.

Input
IPresenterResponse $response
Output
void  
Throws
throws AbortException