Open Journal Systems  3.3.0
PKPRouter Class Reference
Inheritance diagram for PKPRouter:
APIRouter PKPComponentRouter PKPPageRouter PageRouter

Public Member Functions

 __construct ()
 
 _authorizeInitializeAndCallRequest (&$serviceEndpoint, $request, &$args, $validate=true)
 
 _contextLevelToContextName ($contextLevel)
 
 _contextNameToContextLevel ($contextName)
 
 _urlCanonicalizeNewContext ($newContext)
 
 _urlFromParts ($baseUrl, $pathInfoArray=array(), $queryParametersArray=array(), $anchor='', $escape=false)
 
 _urlGetAdditionalParameters ($request, $params=null, $escape=true)
 
 _urlGetBaseAndContext ($request, $newContext=array())
 
getApplication ()
 
 getCacheFilename ($request)
 
getContext ($request, $requestedContextLevel=1, $forceReload=false)
 
getContextByName ($request, $requestedContextName)
 
getDispatcher ()
 
 getHandler ()
 
 getIndexUrl ($request)
 
 getRequestedContextPath ($request, $requestedContextLevel=1)
 
 getRequestedContextPaths ($request)
 
 handleAuthorizationFailure ($request, $authorizationMessage)
 
 isCacheable ($request)
 
 route ($request)
 
 setApplication ($application)
 
 setDispatcher ($dispatcher)
 
 setHandler ($handler)
 
 supports ($request)
 
 url ($request, $newContext=null, $handler=null, $op=null, $path=null, $params=null, $anchor=null, $escape=false)
 

Data Fields

 $_application
 
 $_contextDepth
 
 $_contextList
 
 $_contextPaths = array()
 
 $_contexts = array()
 
 $_dispatcher
 
 $_flippedContextList
 
 $_handler
 

Detailed Description

Basic router class that has functionality common to all routers.

See also
PKPPageRouter
PKPComponentRouter

NB: All handlers provide the common basic workflow. The router calls the following methods in the given order. 1) constructor: Handlers should establish a mapping of remote operations to roles that may access them. They do so by calling PKPHandler::addRoleAssignment(). 2) authorize(): Authorizes the request, among other things based on the result of the role assignment created during object instantiation. If authorization fails then die with a fatal error or execute the "call- on-deny" advice if one has been defined in the authorization policy that denied access. 3) validate(): Let the handler execute non-fatal data integrity checks (FIXME: currently only for component handlers). Please make sure that data integrity checks that can lead to denial of access are being executed in the authorize() step via authorization policies and not here. 4) initialize(): Let the handler initialize its internal state based on authorized and valid data. Authorization and integrity checks should be kept out of here to get a clear separation of concerns. 5) execution: Executes the requested handler operation. The mapping of requests to operations depends on the router implementation (see the class doc of specific router implementations for more details). 6) client response: Handlers should return a string value that will then be returned to the client as a response. Handler operations should not output the response directly to the client so that we can run filter operations on the output if required. Outputting text from handler operations to the client is possible but deprecated.

Definition at line 57 of file PKPRouter.inc.php.

Constructor & Destructor Documentation

◆ __construct()

PKPRouter::__construct ( )

Constructor

Definition at line 107 of file PKPRouter.inc.php.

Member Function Documentation

◆ _authorizeInitializeAndCallRequest()

PKPRouter::_authorizeInitializeAndCallRequest ( $serviceEndpoint,
  $request,
$args,
  $validate = true 
)

This is the method that implements the basic life-cycle of a handler request: 1) authorization 2) validation 3) initialization 4) execution 5) client response

Parameters
$serviceEndpointcallable the handler operation
$requestPKPRequest
$argsarray
$validateboolean whether or not to execute the validation step.

Definition at line 393 of file PKPRouter.inc.php.

References getDispatcher(), and handleAuthorizationFailure().

Referenced by PKPPageRouter\route(), and PKPComponentRouter\route().

◆ _contextLevelToContextName()

PKPRouter::_contextLevelToContextName (   $contextLevel)

Convert a context level to its corresponding context name.

Parameters
$contextLevelinteger
Returns
string context name

Definition at line 639 of file PKPRouter.inc.php.

Referenced by getContext().

◆ _contextNameToContextLevel()

PKPRouter::_contextNameToContextLevel (   $contextName)

Convert a context name to its corresponding context level.

Parameters
$contextNamestring
Returns
integer context level

Definition at line 649 of file PKPRouter.inc.php.

Referenced by getContextByName().

◆ _urlCanonicalizeNewContext()

PKPRouter::_urlCanonicalizeNewContext (   $newContext)

Canonicalizes the new context.

A new context can be given as a scalar. In this case only the first context will be replaced. If the context depth of the current application is higher than one than the context can also be given as an array if more than the first context should be replaced. We therefore canonicalize the new context to an array.

When all entries are of the form 'contextName' => null or if $newContext == null then we'll return an empty array.

Parameters
$newContextthe raw context array
Returns
array the canonicalized context array

Definition at line 452 of file PKPRouter.inc.php.

Referenced by APIRouter\url(), PKPPageRouter\url(), and PKPComponentRouter\url().

◆ _urlFromParts()

PKPRouter::_urlFromParts (   $baseUrl,
  $pathInfoArray = array(),
  $queryParametersArray = array(),
  $anchor = '',
  $escape = false 
)

Creates a valid URL from parts.

Parameters
$baseUrlstring the protocol, domain and initial path/parameters, no anchors allowed here
$pathInfoArrayarray strings to be concatenated as path info
$queryParametersArrayarray strings to be concatenated as query string
$anchorstring an additional anchor
$escapeboolean whether to escape ampersands
Returns
string the URL

Definition at line 582 of file PKPRouter.inc.php.

Referenced by APIRouter\url(), PKPPageRouter\url(), and PKPComponentRouter\url().

◆ _urlGetAdditionalParameters()

PKPRouter::_urlGetAdditionalParameters (   $request,
  $params = null,
  $escape = true 
)

Build the additional parameters part of the URL.

Parameters
$requestPKPRequest the request to be routed
$paramsarray (optional) the parameter list to be transformed to a url part.
$escapeboolean (optional) Whether or not to escape structural elements
Returns
array the encoded parameters or an empty array if no parameters were given.

Definition at line 555 of file PKPRouter.inc.php.

Referenced by APIRouter\url(), PKPPageRouter\url(), and PKPComponentRouter\url().

◆ _urlGetBaseAndContext()

PKPRouter::_urlGetBaseAndContext (   $request,
  $newContext = array() 
)

Build the base URL and add the context part of the URL.

The new URL will be based on the current request's context if no new context is given.

The base URL for a given primary context can be overridden in the config file using the 'base_url[context]' syntax in the config file's 'general' section.

Parameters
$requestPKPRequest the request to be routed
$newContextmixed (optional) context that differs from the current request's context
Returns
array An array consisting of the base url as the first entry and the context as the remaining entries.

Definition at line 487 of file PKPRouter.inc.php.

References $_contextList, getContextByName(), getIndexUrl(), and Config\getVar().

Referenced by APIRouter\url(), PKPPageRouter\url(), and PKPComponentRouter\url().

◆ getApplication()

◆ getCacheFilename()

PKPRouter::getCacheFilename (   $request)

Determine the filename to use for a local cache file.

Parameters
$requestPKPRequest
Returns
string

Reimplemented in PKPPageRouter.

Definition at line 331 of file PKPRouter.inc.php.

◆ getContext()

& PKPRouter::getContext (   $request,
  $requestedContextLevel = 1,
  $forceReload = false 
)

A Generic call to a context defining object (e.g. a Press, a Conference, or a SchedConf)

Parameters
$requestPKPRequest the request to be routed
$requestedContextLevelint (optional) the desired context level
$forceReloadboolean (optional) Reset a context even if it's already been loaded
Returns
object

Definition at line 250 of file PKPRouter.inc.php.

References _contextLevelToContextName(), DAORegistry\getDAO(), and getRequestedContextPath().

Referenced by getContextByName(), and PKPPageRouter\getHomeUrl().

◆ getContextByName()

& PKPRouter::getContextByName (   $request,
  $requestedContextName 
)

Get the object that represents the desired context (e.g. Conference or Press)

Parameters
$requestPKPRequest the request to be routed
$requestedContextNamestring page context
Returns
object

Definition at line 289 of file PKPRouter.inc.php.

References _contextNameToContextLevel(), and getContext().

Referenced by _urlGetBaseAndContext().

◆ getDispatcher()

& PKPRouter::getDispatcher ( )

get the dispatcher

Returns
Dispatcher

Definition at line 136 of file PKPRouter.inc.php.

References $_dispatcher.

Referenced by _authorizeInitializeAndCallRequest(), and PKPPageRouter\route().

◆ getHandler()

PKPRouter::getHandler ( )

Get the handler object.

Returns
PKPHandler

Definition at line 161 of file PKPRouter.inc.php.

References $_handler.

Referenced by APIRouter\getRequestedOp().

◆ getIndexUrl()

PKPRouter::getIndexUrl (   $request)

Get the URL to the index script.

Parameters
$requestPKPRequest the request to be routed
Returns
string

Definition at line 309 of file PKPRouter.inc.php.

References HookRegistry\call().

Referenced by _urlGetBaseAndContext().

◆ getRequestedContextPath()

PKPRouter::getRequestedContextPath (   $request,
  $requestedContextLevel = 1 
)

A generic method to return a single context path (e.g. a Press or a SchedConf path)

Parameters
$requestPKPRequest the request to be routed
$requestedContextLevelint (optional) the context level to return
Returns
string

Definition at line 229 of file PKPRouter.inc.php.

References getRequestedContextPaths().

Referenced by getContext().

◆ getRequestedContextPaths()

PKPRouter::getRequestedContextPaths (   $request)

A generic method to return an array of context paths (e.g. a Press or a Conference/SchedConf paths)

Parameters
$requestPKPRequest the request to be routed
$requestedContextLevelint (optional) the context level to return in the path
Returns
array of string (each element the path to one context element)

Definition at line 191 of file PKPRouter.inc.php.

References $_contextPaths, HookRegistry\call(), and Core\getContextPaths().

Referenced by getRequestedContextPath().

◆ handleAuthorizationFailure()

PKPRouter::handleAuthorizationFailure (   $request,
  $authorizationMessage 
)

Handle an authorization failure.

Parameters
$requestRequest
$authorizationMessagestring a translation key with the authorization failure message.

Reimplemented in PKPPageRouter, PKPComponentRouter, and APIRouter.

Definition at line 369 of file PKPRouter.inc.php.

Referenced by _authorizeInitializeAndCallRequest().

◆ isCacheable()

PKPRouter::isCacheable (   $request)

Determine whether or not this request is cacheable

Parameters
$requestPKPRequest
Returns
boolean

Definition at line 180 of file PKPRouter.inc.php.

◆ route()

PKPRouter::route (   $request)

Routes a given request to a handler operation

Parameters
$requestPKPRequest

Reimplemented in PKPComponentRouter, PKPPageRouter, and APIRouter.

Definition at line 340 of file PKPRouter.inc.php.

◆ setApplication()

PKPRouter::setApplication (   $application)

set the application

Parameters
$applicationPKPApplication

Definition at line 123 of file PKPRouter.inc.php.

References $application.

◆ setDispatcher()

PKPRouter::setDispatcher (   $dispatcher)

set the dispatcher

Parameters
$dispatcherPKPDispatcher

Definition at line 145 of file PKPRouter.inc.php.

◆ setHandler()

PKPRouter::setHandler (   $handler)

Set the handler object for later retrieval.

Parameters
$handlerPKPHandler

Definition at line 153 of file PKPRouter.inc.php.

Referenced by PKPComponentRouter\getRpcServiceEndpoint(), APIRouter\route(), and PKPPageRouter\route().

◆ supports()

PKPRouter::supports (   $request)

Determines whether this router can route the given request.

Parameters
$requestPKPRequest
Returns
boolean true, if the router supports this request, otherwise false

Reimplemented in PKPComponentRouter, and APIRouter.

Definition at line 170 of file PKPRouter.inc.php.

◆ url()

PKPRouter::url (   $request,
  $newContext = null,
  $handler = null,
  $op = null,
  $path = null,
  $params = null,
  $anchor = null,
  $escape = false 
)

Build a handler request URL into PKPApplication.

Parameters
$requestPKPRequest the request to be routed
$newContextmixed Optional contextual paths
$handlerstring Optional name of the handler to invoke
$opstring Optional name of operation to invoke
$pathmixed Optional string or array of args to pass to handler
$paramsarray Optional set of name => value pairs to pass as user parameters
$anchorstring Optional name of anchor to add to URL
$escapeboolean Whether or not to escape ampersands, square brackets, etc. for this URL; default false.
Returns
string the URL

Reimplemented in PKPPageRouter, APIRouter, and PKPComponentRouter.

Definition at line 357 of file PKPRouter.inc.php.

Field Documentation

◆ $_application

PKPApplication PKPRouter::$_application

Definition at line 67 of file PKPRouter.inc.php.

Referenced by getApplication().

◆ $_contextDepth

integer PKPRouter::$_contextDepth

context depth

Definition at line 77 of file PKPRouter.inc.php.

◆ $_contextList

integer PKPRouter::$_contextList

context list

Definition at line 82 of file PKPRouter.inc.php.

Referenced by _urlGetBaseAndContext().

◆ $_contextPaths

integer PKPRouter::$_contextPaths = array()

context paths

Definition at line 92 of file PKPRouter.inc.php.

Referenced by getRequestedContextPaths().

◆ $_contexts

integer PKPRouter::$_contexts = array()

contexts

Definition at line 97 of file PKPRouter.inc.php.

◆ $_dispatcher

Dispatcher PKPRouter::$_dispatcher

Definition at line 72 of file PKPRouter.inc.php.

Referenced by getDispatcher().

◆ $_flippedContextList

integer PKPRouter::$_flippedContextList

context list with keys and values flipped

Definition at line 87 of file PKPRouter.inc.php.

◆ $_handler

PKPHandler PKPRouter::$_handler

Handler class

Definition at line 102 of file PKPRouter.inc.php.

Referenced by getHandler().


The documentation for this class was generated from the following file: