PHP Class Piwik\FrontController

Piwik uses this class for all requests that go through **index.php**. Plugins can use it to call controller actions of other plugins. ### Examples **Forwarding controller requests** public function myConfiguredRealtimeMap() { $_GET['changeVisitAlpha'] = false; $_GET['removeOldVisits'] = false; $_GET['showFooterMessage'] = false; return FrontController::getInstance()->dispatch('UserCountryMap', 'realtimeMap'); } **Using other plugin controller actions** public function myPopupWithRealtimeMap() { $_GET['changeVisitAlpha'] = false; $_GET['removeOldVisits'] = false; $_GET['showFooterMessage'] = false; $realtimeMap = FrontController::getInstance()->dispatch('UserCountryMap', 'realtimeMap'); $view = new View('@MyPlugin/myPopupWithRealtimeMap.twig'); $view->realtimeMap = $realtimeMap; return $realtimeMap->render(); } For a detailed explanation, see the documentation here.
Inheritance: extends piwik\Singleton
ファイルを表示 Open project: piwik/piwik Class Usage Examples

Public Properties

Property Type Description
$enableDispatch boolean Set to false and the Front Controller will not dispatch the request

Public Methods

Method Description
__destruct ( ) Called at the end of the page generation
dispatch ( string $module = null, string $action = null, array $parameters = null ) : void | mixed Executes the requested plugin controller method.
fetchDispatch ( string $module = null, string $actionName = null, array $parameters = null ) : string Executes the requested plugin controller method and returns the data, capturing anything the method echos.
init ( ) : void Must be called before dispatch() - checks that directories are writable, - loads the configuration file, - loads the plugin, - inits the DB connection, - etc.
setUpSafeMode ( )
shouldRethrowException ( ) Should we show exceptions messages directly rather than display an html error page?
triggerSafeModeWhenError ( )

Protected Methods

Method Description
handleMaintenanceMode ( )
handleSSLRedirection ( )
prepareDispatch ( $module, $action, $parameters )

Private Methods

Method Description
closeSessionEarlyForFasterUI ( )
doDispatch ( $module, $action, $parameters ) : mixed
generateSafeModeOutput ( $lastError ) : mixed | void
handleProfiler ( )
throwIfPiwikVersionIsOlderThanDBSchema ( ) This method ensures that Piwik Platform cannot be running when using a NEWER database.

Method Details

__destruct() public method

Called at the end of the page generation
public __destruct ( )

dispatch() public method

Executes the requested plugin controller method.
public dispatch ( string $module = null, string $action = null, array $parameters = null ) : void | mixed
$module string The name of the plugin whose controller to execute, eg, `'UserCountryMap'`.
$action string The controller method name, eg, `'realtimeMap'`.
$parameters array Array of parameters to pass to the controller method.
return void | mixed The returned value of the call. This is the output of the controller method.

fetchDispatch() public method

_Note: If the plugin controller returns something, the return value is returned instead of whatever is in the output buffer._
Deprecation:
public fetchDispatch ( string $module = null, string $actionName = null, array $parameters = null ) : string
$module string The name of the plugin whose controller to execute, eg, `'UserCountryMap'`.
$actionName string The controller action name, eg, `'realtimeMap'`.
$parameters array Array of parameters to pass to the controller action method.
return string The `echo`'d data or the return value of the controller action.

handleMaintenanceMode() protected method

protected handleMaintenanceMode ( )

handleSSLRedirection() protected method

protected handleSSLRedirection ( )

init() public method

Must be called before dispatch() - checks that directories are writable, - loads the configuration file, - loads the plugin, - inits the DB connection, - etc.
public init ( ) : void
return void

prepareDispatch() protected method

protected prepareDispatch ( $module, $action, $parameters )

setUpSafeMode() public static method

public static setUpSafeMode ( )

shouldRethrowException() public static method

Should we show exceptions messages directly rather than display an html error page?
public static shouldRethrowException ( )

triggerSafeModeWhenError() public static method

public static triggerSafeModeWhenError ( )

Property Details

$enableDispatch public_oe static_oe property

Set to false and the Front Controller will not dispatch the request
public static bool $enableDispatch
return boolean