Skip to content
Extraits de code Groupes Projets
Valider c2cb0409 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

refs #4199 documented some more events

parent 3f39037b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
<Files "*">
<IfModule mod_access.c>
Deny from all
</IfModule>
<IfModule !mod_access_compat>
<IfModule mod_authz_host.c>
Deny from all
</IfModule>
</IfModule>
<IfModule mod_access_compat>
Deny from all
</IfModule>
</Files>
......@@ -180,7 +180,19 @@ class Proxy
// allow plugins to manipulate the value
$pluginName = $this->getModuleNameFromClassName($className);
/**
* Generic hook that plugins can use to modify any input to any API method. You could also use this to build
* an enhanced permission system. The event is triggered shortly before any API method is executed.
*
* The `$fnalParameters` contains all paramteres that will be passed to the actual API method.
*/
Piwik_PostEvent(sprintf('API.Request.dispatch', $pluginName, $methodName), array(&$finalParameters));
/**
* This event is similar to the `API.Request.dispatch` event. It distinguishes the possibility to subscribe
* only to a specific API method instead of all API methods. You can use it for example to modify any input
* parameters or to execute any other logic before the actual API method is called.
*/
Piwik_PostEvent(sprintf('API.%s.%s', $pluginName, $methodName), array(&$finalParameters));
// call the method
......@@ -193,7 +205,40 @@ class Proxy
'action' => $methodName,
'parameters' => $finalParameters)
);
/**
* This event is similar to the `API.Request.dispatch.end` event. It distinguishes the possibility to
* subscribe only to the end of a specific API method instead of all API methods. You can use it for example
* to modify the response. The passed parameters contains the returned value as well as some additional
* meta information:
*
* ```
* function (
* &$returnedValue,
* array('className' => $className,
* 'module' => $pluginName,
* 'action' => $methodName,
* 'parameters' => $finalParameters)
* );
* ```
*/
Piwik_PostEvent(sprintf('API.%s.%s.end', $pluginName, $methodName), $endHookParams);
/**
* Generic hook that plugins can use to modify any output of any API method. The event is triggered after
* any API method is executed but before the result is send to the user. The parameters originally
* passed to the controller are available as well:
*
* ```
* function (
* &$returnedValue,
* array('className' => $className,
* 'module' => $pluginName,
* 'action' => $methodName,
* 'parameters' => $finalParameters)
* );
* ```
*/
Piwik_PostEvent(sprintf('API.Request.dispatch.end', $pluginName, $methodName), $endHookParams);
// Restore the request
......
......@@ -181,6 +181,12 @@ class Request
// if a token_auth is specified in the API request, we load the right permissions
$token_auth = Common::getRequestVar('token_auth', '', 'string', $request);
if ($token_auth) {
/**
* This event will be triggered if the token_auth is found in the $request parameter. In this case the
* current session will be authenticated using this token_auth. It will overwrite the previous Auth object.
* @matt
*/
Piwik_PostEvent('API.Request.authenticate', array($token_auth));
Access::getInstance()->reloadAccess();
SettingsServer::raiseMemoryLimitIfNecessary();
......
......@@ -104,6 +104,21 @@ class Day extends ArchiveProcessor
protected function compute()
{
/**
* This event is triggered when the archiver wants to compute a new archive. Use this event to archive your
* custom report data if needed.
*
* Example:
* ```
* public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
* {
* $archiving = new Archiver($archiveProcessor);
* if ($archiving->shouldArchive()) {
* $archiving->archiveDay();
* }
* }
* ```
*/
Piwik_PostEvent('ArchiveProcessor.Day.compute', array(&$this));
}
}
......@@ -186,6 +186,21 @@ class Period extends ArchiveProcessor
protected function compute()
{
/**
* This event is triggered when the archiver wants to compute a new archive. Use this event to archive your
* custom report data if needed.
*
* Example:
* ```
* public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
* {
* $archiving = new Archiver($archiveProcessor);
* if ($archiving->shouldArchive()) {
* $archiving->archivePeriod();
* }
* }
* ```
*/
Piwik_PostEvent('ArchiveProcessor.Period.compute', array(&$this));
}
......
......@@ -131,6 +131,9 @@ class Schema
private function loadSchema()
{
$schema = null;
/**
* @matt can be removed?
*/
Piwik_PostEvent('Schema.loadSchema', array(&$schema));
if ($schema === null) {
$config = Config::getInstance();
......
......@@ -128,7 +128,7 @@ class FrontController
* called. You could also use this to build an enhanced permission system. The event is triggered before any
* controller is called.
*
* The `$params array contains the following properties: `array($module, $action, $parameters, $controller)`
* The `$params` array contains the following properties: `array($module, $action, $parameters, $controller)`
*/
Piwik_PostEvent('Request.dispatch', $params);
......
......@@ -39,6 +39,27 @@ class Admin extends MenuAbstract
public function get()
{
if (!$this->menu) {
/**
* This event is triggered to collect all available admin menu items. Subscribe to this event if you want
* to add one or more items to the Piwik admin menu. It's fairly easy. Just define the name of your menu
* item as well as a controller and an action that should be executed once a user selects your menu item.
* It is also possible to display the item only for users having a specific role.
*
* Example:
* ```
* public function addMenuItems()
* {
* Piwik_AddAdminSubMenu(
* 'MenuName',
* 'SubmenuName',
* array('module' => 'MyPlugin', 'action' => 'index'),
* Piwik::isUserIsSuperUser(),
* $order = 6
* );
* }
* ```
*/
Piwik_PostEvent('Menu.Admin.addItems');
}
return parent::get();
......
......@@ -59,6 +59,27 @@ class Main extends MenuAbstract
{
// We trigger the Event only once!
if (!$this->menu) {
/**
* This event is triggered to collect all available reporting menu items. Subscribe to this event if you
* want to add one or more items to the Piwik reporting menu. It's fairly easy. Just define the name of your
* menu item as well as a controller and an action that should be executed once a user selects your menu
* item. It is also possible to display the item only for users having a specific role.
*
* Example:
* ```
* public function addMenuItems()
* {
* Piwik_AddMenu(
* 'CustomMenuName',
* 'CustomSubmenuName',
* array('module' => 'MyPlugin', 'action' => 'index'),
* Piwik::isUserIsSuperUser(),
* $order = 6
* );
* }
* ```
*/
Piwik_PostEvent('Menu.Reporting.addItems');
}
return parent::get();
......
......@@ -59,6 +59,27 @@ class Top extends MenuAbstract
public function get()
{
if (!$this->menu) {
/**
* This event is triggered to collect all available menu items that should be displayed on the very top next
* to login/logout, API and other menu items. Subscribe to this event if you want to add one or more items.
* It's fairly easy. Just define the name of your menu item as well as a controller and an action that
* should be executed once a user selects your menu item. It is also possible to display the item only for
* users having a specific role.
*
* Example:
* ```
* public function addMenuItems()
* {
* Piwik_AddTopMenu(
* 'TopMenuName',
* array('module' => 'MyPlugin', 'action' => 'index'),
* Piwik::isUserIsSuperUser(),
* $order = 6
* );
* }
* ```
*/
Piwik_PostEvent('Menu.Top.addItems');
}
return parent::get();
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter