Class Presenter (namespace Nette\Application)


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

Implements interfaces:

IPresenter
Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Abstract:
Located: in /Application/Presenter.php (line 40)
Constructor Summary
public
Method Summary
protected void
Common render method.
string
Link to myself.
protected void
Common prepare method.
protected void
Common render method.
void
Conditional redirect to canonicalized URI.
void
changeLayout (string|FALSE $layout)
Changes or disables layout.
void
changeScene (string $scene)
Changes current view scene. Any name is allowed.
void
changeView (string $view)
Changes current view. Only alphanumeric characters are allowed.
protected IAjaxDriver
protected string
createRequest (PresenterComponent $component, string $destination, $args, string $mode)
PresenterRequest/URL factory.
protected array
formatLayoutTemplateFiles (string $presenter, string $layout)
Formats layout template file names.
protected static string
formatPrepareMethod (string $scene)
Formats prepare scene method name.
protected static string
formatPresentMethod (string $view)
Formats execute method name.
protected static string
formatRenderMethod (string $scene)
Formats render scene method name.
protected array
formatTemplateFiles (string $presenter, string $scene)
Formats scene template file names.
void
forward (string|PresenterRequest $destination, [array|mixed $args = array()])
Forward to another presenter or view.
IAjaxDriver|NULL
Application
SesssionNamespace
Returns session namespace provided to pass temporary data between redirects.
protected IHttpRequest
protected IHttpResponse
PresenterRequest
Returns the last created PresenterRequest.
bool
getLastCreatedRequestFlag (string $flag)
Returns the last created PresenterRequest flag.
string|FALSE
Returns current layout name.
int
Returns current presenter life cycle phase.
Presenter
getPresenter ([$need = TRUE])
Returns self.
PresenterRequest
getRequest ([bool $clone = TRUE])
string
Returns current scene name.
array|NULL
Returns pair signal receiver and name.
string
Returns a name that uniquely identifies component.
string
getView ([$fullyQualified = FALSE])
Returns current view name.
protected string
Invalid link handler.
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.
protected void
void
redirectUri (string $uri, [int $code = IHttpResponse::S303_POST_GET])
Redirect to another URL and ends presenter execution.
protected void
void
run ()
protected void
Permanently saves state information for all subcomponents to $this->globalState.
protected void
protected void
startup ()
void
Correctly terminates presenter.
Methods Inherited From Control
Control::createTemplate(), Control::flashMessage(), Control::getSnippetId(), Control::getTemplate(), Control::invalidateControl(), Control::isControlInvalid(), Control::validateControl()
Methods Inherited From PresenterComponent
PresenterComponent::__construct(), PresenterComponent::ajaxLink(), PresenterComponent::attached(), PresenterComponent::formatSignalMethod(), PresenterComponent::getParam(), PresenterComponent::getParamId(), PresenterComponent::getPresenter(), PresenterComponent::getUniqueId(), PresenterComponent::lazyLink(), PresenterComponent::link(), PresenterComponent::loadState(), PresenterComponent::redirect(), PresenterComponent::saveState(), PresenterComponent::signalReceived(), PresenterComponent::tryCall()
Methods Inherited From ComponentContainer
ComponentContainer::addComponent(), ComponentContainer::createComponent(), ComponentContainer::getComponent(), ComponentContainer::getComponents(), ComponentContainer::isCloning(), ComponentContainer::removeComponent(), ComponentContainer::validateChildComponent(), ComponentContainer::__clone()
Methods Inherited From Component
Component::__construct(), Component::attached(), Component::detached(), Component::getName(), Component::getParent(), Component::getService(), Component::getServiceLocator(), Component::lookup(), Component::lookupPath(), Component::monitor(), Component::setParent(), Component::setServiceLocator(), Component::validateParent(), Component::__clone(), Component::__wakeup()
Methods Inherited From Object
Object::extensionMethod(), Object::getClass(), Object::getReflection(), Object::__call(), Object::__callStatic(), Object::__get(), Object::__isset(), Object::__set(), Object::__unset()
Constant Summary
string FLASH_KEY '_fid'

line 59

special parameter key
int PHASE_PREPARE 2

line 44

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

line 46

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

line 47

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

line 45

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

line 43

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

line 57

special parameter key
string VIEW_KEY 'view'

line 58

special parameter key
Variable Summary
bool $autoCanonicalize TRUE

line 78

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

line 63

static int $invalidLinkMode

line 66

array $onShutdown

line 69

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

Constructor Details

line 121

__construct

public __construct (PresenterRequest $request)

Input
PresenterRequest $request
Method Details

line 287

afterRender

protected void afterRender ()

Common render method.

Output
void  

line 267

beforePrepare

protected void beforePrepare ()

Common prepare method.

Output
void  

line 277

beforeRender

protected void beforeRender ()

Common render method.

Output
void  

line 737

canonicalize

public void canonicalize ()

Conditional redirect to canonicalized URI.

Output
void  
Throws
throws AbortException

line 445

changeLayout

public void changeLayout (string|FALSE $layout)

Changes or disables layout.

Input
string|FALSE $layout
Output
void  

line 422

changeScene

public void changeScene (string $scene)

Changes current view scene. Any name is allowed.

Input
string $scene
Output
void  

line 393

changeView

public void changeView (string $view)

Changes current view. Only alphanumeric characters are allowed.

Input
string $view
Output
void  

line 632

createAjaxDriver

protected IAjaxDriver createAjaxDriver ()

Output
IAjaxDriver  

line 830

createRequest

protected string createRequest (PresenterComponent $component, string $destination, $args, string $mode)

PresenterRequest/URL factory.

Input
PresenterComponent $component base
string $destination destination in format "[[module:]presenter:]view" or "signal!"
$args array of arguments
string $mode forward|redirect|link
Output
string URL
Throws
throws InvalidLinkException

line 509

formatLayoutTemplateFiles

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

Formats layout template file names.

Input
string $presenter
string $layout
Output
array  

line 574

formatPrepareMethod

protected static string formatPrepareMethod (string $scene)

Formats prepare scene method name.

Input
string $scene
Output
string  

line 562

formatPresentMethod

protected static string formatPresentMethod (string $view)

Formats execute method name.

Input
string $view
Output
string  

line 586

formatRenderMethod

protected static string formatRenderMethod (string $scene)

Formats render scene method name.

Input
string $scene
Output
string  

line 540

formatTemplateFiles

protected array formatTemplateFiles (string $presenter, string $scene)

Formats scene template file names.

Input
string $presenter
string $scene
Output
array  

line 650

forward

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

Forward to another presenter or view.

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

line 614

getAjaxDriver

public IAjaxDriver|NULL getAjaxDriver ()

Output
IAjaxDriver|NULL  

line 1263

getApplication

public Application getApplication ()

Output
Application  

line 1226

getFlashSession

public SesssionNamespace getFlashSession ()

Returns session namespace provided to pass temporary data between redirects.

Output
SesssionNamespace  

line 1243

getHttpRequest

protected IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 1253

getHttpResponse

protected IHttpResponse getHttpResponse ()

Output
IHttpResponse  

line 701

getLastCreatedRequest

public PresenterRequest getLastCreatedRequest ()

Returns the last created PresenterRequest.

Output
PresenterRequest  

line 713

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 247

getPhase

public int getPhase ()

Returns current presenter life cycle phase.

Output
int  

line 144

getPresenter

public Presenter getPresenter ([$need = TRUE])

Returns self.

Input
$need
Output
Presenter  

line 133

getRequest

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

Input
bool $clone
Output
PresenterRequest  

line 410

getScene

public string getScene ()

Returns current scene name.

Output
string  

line 337

getSignal

public array|NULL getSignal ()

Returns pair signal receiver and name.

Output
array|NULL  

line 155

getUniqueId

public string getUniqueId ()

Returns a name that uniquely identifies component.

Output
string  

line 381

getView

public string getView ([$fullyQualified = FALSE])

Returns current view name.

Input
$fullyQualified
Output
string  

line 1214

hasFlashSession

public bool hasFlashSession ()

Checks if a flash session namespace exists.

Output
bool  

line 601

isAjax

public bool isAjax ()

Is AJAX request?

Output
bool  

line 350

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 757

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 AbortException

line 1192

popGlobalParams

public array popGlobalParams (string $id)

Pops parameters for specified component.

Input
string $id component id
Output
array  

line 310

processSignal

protected void processSignal ()

Output
void  
Throws
throws BadSignalException

line 673

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 456

renderTemplate

protected void renderTemplate ()

Output
void  
Throws
throws BadRequestException if no template found

line 170

run

public void run ()

Implementation of:

Output
void  
Throws
throws AbortException

line 1129

saveGlobalState

protected void saveGlobalState ()

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

Output
void  

line 296

shutdown

protected void shutdown ()

Output
void  

line 257

startup

protected void startup ()

Output
void  

line 725

terminate

public void terminate ()

Correctly terminates presenter.

Output
void  
Throws
throws AbortException