Class Presenter (namespace Nette\Application)


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

Implements interfaces:

Copyright: Copyright (c) 2004, 2010 David Grudl
Abstract:
Located: in /Application/Presenter.php (line 30)
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.
void
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.
void
lastModified (string|int|DateTime $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
Sends AJAX payload to the output.
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 HttpContext
protected HttpRequest
protected HttpResponse
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
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(), getReflection(), 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 42

bad link handling Presenter::$invalidLinkMode
INVALID_LINK_SILENT 1

line 40

bad link handling Presenter::$invalidLinkMode
INVALID_LINK_WARNING 2

line 41

bad link handling Presenter::$invalidLinkMode
int PHASE_RENDER 4

line 35

int PHASE_SHUTDOWN 5

line 36

int PHASE_SIGNAL 3

line 34

int PHASE_STARTUP 1

line 33

Variable Summary
bool $absoluteUrls FALSE

line 79

use absolute Urls or paths?
bool $autoCanonicalize TRUE

line 76

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

line 52

static int $invalidLinkMode

line 55

bool $oldLayoutMode TRUE

line 61

(experimental)
bool $oldModuleMode TRUE

line 64

(experimental)
array $onShutdown

line 58

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

Method Details

line 285

afterRender

protected void afterRender ()

Common render method.

Output
void  

line 275

beforeRender

protected void beforeRender ()

Common render method.

Output
void  

line 773

canonicalize

public void canonicalize ()

Conditional redirect to canonicalized URI.

Output
void  
Throws
throws AbortException

line 392

changeAction

public void changeAction (string $action)

Changes current action. Only alphanumeric characters are allowed.

Input
string $action
Output
void  

line 593

formatActionMethod

protected static string formatActionMethod (string $action)

Formats action method name.

Input
string $action
Output
string  

line 513

formatLayoutTemplateFiles

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

Formats layout template file names.

Input
string $presenter
string $layout
Output
array  

line 605

formatRenderMethod

protected static string formatRenderMethod (string $view)

Formats render view method name.

Input
string $view
Output
string  

line 557

formatTemplateFiles

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

Formats view template file names.

Input
string $presenter
string $view
Output
array  

line 683

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 380

getAction

public string getAction ([$fullyQualified = FALSE])

Returns current action name.

Input
$fullyQualified
Output
string  

line 665

getAjaxDriver

public void getAjaxDriver ()

Output
void  
Tags
Deprecated

line 1349

getApplication

public Application getApplication ()

Output
Application  

line 1302

getFlashSession

public SessionNamespace getFlashSession ()

Returns session namespace provided to pass temporary data between redirects.

Output
SessionNamespace  

line 1339

getHttpContext

protected HttpContext getHttpContext ()

Output
HttpContext  

line 1319

getHttpRequest

protected HttpRequest getHttpRequest ()

Output
HttpRequest  

line 1329

getHttpResponse

protected HttpResponse getHttpResponse ()

Output
HttpResponse  

line 735

getLastCreatedRequest

public PresenterRequest getLastCreatedRequest ()

Returns the last created PresenterRequest.

Output
PresenterRequest  

line 747

getLastCreatedRequestFlag

public bool getLastCreatedRequestFlag (string $flag)

Returns the last created PresenterRequest flag.

Input
string $flag
Output
bool  

line 433

getLayout

public string|FALSE getLayout ()

Returns current layout name.

Output
string|FALSE  

line 629

getPayload

public stdClass getPayload ()

Output
stdClass  

line 1120

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 253

getPhase

public void getPhase ()

Output
void  
Tags
Deprecated

line 136

getPresenter

public Presenter getPresenter ([$need = TRUE])

Returns self.

Input
$need
Output
Presenter  

line 125

getRequest

public PresenterRequest getRequest ()

Output
PresenterRequest  

line 1359

getSession

protected Session getSession ([$namespace = NULL])

Input
$namespace
Output
Session  

line 336

getSignal

public array|NULL getSignal ()

Returns pair signal receiver and name.

Output
array|NULL  

line 147

getUniqueId

public string getUniqueId ()

Returns a name that uniquely identifies component.

Output
string  

line 1369

getUser

protected User getUser ()

Output
User  

line 409

getView

public string getView ()

Returns current view.

Output
string  

line 1290

hasFlashSession

public bool hasFlashSession ()

Checks if a flash session namespace exists.

Output
bool  

line 640

isAjax

public bool isAjax ()

Is AJAX request?

Output
bool  

line 349

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 794

lastModified

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

Attempts to cache the sent entity by its last modification date

Input
string|int|DateTime $lastModified last modified time
string $etag strong entity tag validator
mixed $expire optional expiration time
Output
void  
Throws
throws AbortException
Tags
Deprecated

line 1268

popGlobalParams

public array popGlobalParams (string $id)

Pops parameters for specified component.

Input
string $id component id
Output
array  

line 309

processSignal

public void processSignal ()

Output
void  
Throws
throws BadSignalException

line 706

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 615

renderTemplate

protected void renderTemplate ()

Output
void  
Tags
Deprecated

line 162

run

public IPresenterResponse run (PresenterRequest $request)

Implementation of:

Input
PresenterRequest $request
Output
IPresenterResponse  

line 1200

saveGlobalState

protected void saveGlobalState ()

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

Output
void  

line 655

sendPayload

public void sendPayload ()

Sends AJAX payload to the output.

Output
void  
Throws
throws AbortException

line 458

sendTemplate

public void sendTemplate ()

Output
void  
Throws
throws AbortException
throws BadRequestException if no template found

line 445

setLayout

public Presenter setLayout (string|FALSE $layout)

Changes or disables layout.

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

line 421

setView

public Presenter setView (string $view)

Changes current view. Any name is allowed.

Input
string $view
Output
Presenter provides a fluent interface

line 295

shutdown

protected void shutdown (IPresenterResponse $response)

Input
IPresenterResponse $response optional catched exception
Output
void  

line 264

startup

protected void startup ()

Output
void  

line 760

terminate

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

Correctly terminates presenter.

Input
IPresenterResponse $response
Output
void  
Throws
throws AbortException