Class NPresenter


NPresenter 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
NLink 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|NPresenterRequest $destination, [array|mixed $args = array()])
Forward to another presenter or action.
string
getAction ([$fullyQualified = FALSE])
Returns current action name.
void
NApplication
NSessionNamespace
Returns session namespace provided to pass temporary data between redirects.
NPresenterRequest
Returns the last created NPresenterRequest.
bool
getLastCreatedRequestFlag (string $flag)
Returns the last created NPresenterRequest flag.
string|FALSE
Returns current layout name.
stdClass
static array
Returns array of persistent components.
int
Returns current presenter life cycle phase.
NPresenter
getPresenter ([$need = TRUE])
Returns self.
NPresenterRequest
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 (NPresenterRequest $request)
void
NPresenter
setLayout (string|FALSE $layout)
Changes or disables layout.
NPresenter
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 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 NControl
createTemplate(), flashMessage(), getSnippetId(), getTemplate(), getWidget(), invalidateControl(), isControlInvalid(), templatePrepareFilters(), validateControl()
Methods Inherited From NPresenterComponent
__construct(), ajaxLink(), attached(), formatSignalMethod(), getParam(), getParamId(), getPersistentParams(), getPresenter(), getUniqueId(), lazyLink(), link(), loadState(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), redirect(), saveState(), signalReceived(), tryCall()
Methods Inherited From NComponentContainer
addComponent(), createComponent(), getComponent(), getComponents(), removeComponent(), validateChildComponent(), __clone()
Methods Inherited From NComponent
__construct(), attached(), detached(), getName(), getParent(), lookup(), lookupPath(), monitor(), setParent(), unmonitor(), validateParent(), __clone(), __wakeup()
Methods Inherited From NObject
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 NPresenter::$invalidLinkMode
INVALID_LINK_SILENT 1

line 54

bad link handling NPresenter::$invalidLinkMode
INVALID_LINK_WARNING 2

line 55

bad link handling NPresenter::$invalidLinkMode
int PHASE_RENDER 4

line 49

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

line 50

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

line 48

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

line 47

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

line 60

special parameter key
Variable Summary
bool $absoluteUrls FALSE

line 90

use absolute Urls or paths?
bool $autoCanonicalize TRUE

line 87

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(NPresenter $sender, IPresenterResponse $response = NULL); Occurs when the presenter is shutting down

Method Details

line 290

afterRender

protected void afterRender ()

Common render method.

Output
void  

line 280

beforeRender

protected void beforeRender ()

Common render method.

Output
void  

line 752

canonicalize

public void canonicalize ()

Conditional redirect to canonicalized URI.

Output
void  
Throws
throws NAbortException

line 397

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 662

forward

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

Forward to another presenter or action.

Input
string|NPresenterRequest $destination
array|mixed $args
Output
void  
Throws
throws NAbortException

line 385

getAction

public string getAction ([$fullyQualified = FALSE])

Returns current action name.

Input
$fullyQualified
Output
string  

line 644

getAjaxDriver

public void getAjaxDriver ()

Output
void  
Tags
Deprecated

line 1318

getApplication

public NApplication getApplication ()

Output
NApplication  

line 1281

getFlashSession

public NSessionNamespace getFlashSession ()

Returns session namespace provided to pass temporary data between redirects.

Output
NSessionNamespace  

line 1298

getHttpRequest

protected IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 1308

getHttpResponse

protected IHttpResponse getHttpResponse ()

Output
IHttpResponse  

line 714

getLastCreatedRequest

public NPresenterRequest getLastCreatedRequest ()

Returns the last created NPresenterRequest.

Output
NPresenterRequest  

line 726

getLastCreatedRequestFlag

public bool getLastCreatedRequestFlag (string $flag)

Returns the last created NPresenterRequest flag.

Input
string $flag
Output
bool  

line 438

getLayout

public string|FALSE getLayout ()

Returns current layout name.

Output
string|FALSE  

line 608

getPayload

public stdClass getPayload ()

Output
stdClass  

line 1095

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 259

getPhase

public int getPhase ()

Returns current presenter life cycle phase.

Output
int  

line 147

getPresenter

public NPresenter getPresenter ([$need = TRUE])

Returns self.

Input
$need
Output
NPresenter  

line 136

getRequest

public NPresenterRequest getRequest ()

Output
NPresenterRequest  

line 341

getSignal

public array|NULL getSignal ()

Returns pair signal receiver and name.

Output
array|NULL  

line 158

getUniqueId

public string getUniqueId ()

Returns a name that uniquely identifies component.

Output
string  

line 414

getView

public string getView ()

Returns current view.

Output
string  

line 1269

hasFlashSession

public bool hasFlashSession ()

Checks if a flash session namespace exists.

Output
bool  

line 619

isAjax

public bool isAjax ()

Is AJAX request?

Output
bool  

line 354

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 772

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 NAbortException

line 1247

popGlobalParams

public array popGlobalParams (string $id)

Pops parameters for specified component.

Input
string $id component id
Output
array  

line 314

processSignal

public void processSignal ()

Output
void  
Throws
throws NBadSignalException

line 685

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 NAbortException

line 594

renderTemplate

protected void renderTemplate ()

Output
void  
Tags
Deprecated

line 173

run

public IPresenterResponse run (NPresenterRequest $request)

Implementation of:

Input
NPresenterRequest $request
Output
IPresenterResponse  

line 1179

saveGlobalState

protected void saveGlobalState ()

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

Output
void  

line 634

sendPayload

protected void sendPayload ()

Sends AJAX payload to the output.

Output
void  
Throws
throws NAbortException

line 463

sendTemplate

public void sendTemplate ()

Output
void  
Throws
throws NAbortException
throws NBadRequestException if no template found

line 450

setLayout

public NPresenter setLayout (string|FALSE $layout)

Changes or disables layout.

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

line 426

setView

public NPresenter setView (string $view)

Changes current view. Any name is allowed.

Input
string $view
Output
NPresenter provides a fluent interface

line 300

shutdown

protected void shutdown (IPresenterResponse $response)

Input
IPresenterResponse $response optional catched exception
Output
void  

line 269

startup

protected void startup ()

Output
void  

line 739

terminate

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

Correctly terminates presenter.

Input
IPresenterResponse $response
Output
void  
Throws
throws NAbortException