本文整理汇总了PHP中Piwik\Piwik::postEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::postEvent方法的具体用法?PHP Piwik::postEvent怎么用?PHP Piwik::postEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Piwik
的用法示例。
在下文中一共展示了Piwik::postEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveFileLocations
protected function retrieveFileLocations()
{
/**
* Triggered when gathering the list of all stylesheets (CSS and LESS) needed by
* Piwik and its plugins.
*
* Plugins that have stylesheets should use this event to make those stylesheets
* load.
*
* Stylesheets should be placed within a **stylesheets** subdirectory in your plugin's
* root directory.
*
* **Example**
*
* public function getStylesheetFiles(&$stylesheets)
* {
* $stylesheets[] = "plugins/MyPlugin/stylesheets/myfile.less";
* $stylesheets[] = "plugins/MyPlugin/stylesheets/myotherfile.css";
* }
*
* @param string[] &$stylesheets The list of stylesheet paths.
*/
Piwik::postEvent('AssetManager.getStylesheetFiles', array(&$this->fileLocations));
$this->addThemeFiles();
}
示例2: createDatabaseObject
/**
* Connects to the database.
*
* Shouldn't be called directly, use {@link get()} instead.
*
* @param array|null $dbInfos Connection parameters in an array. Defaults to the `[database]`
* INI config section.
*/
public static function createDatabaseObject($dbInfos = null)
{
$config = Config::getInstance();
if (is_null($dbInfos)) {
$dbInfos = $config->database;
}
/**
* Triggered before a database connection is established.
*
* This event can be used to change the settings used to establish a connection.
*
* @param array *$dbInfos Reference to an array containing database connection info,
* including:
*
* - **host**: The host name or IP address to the MySQL database.
* - **username**: The username to use when connecting to the
* database.
* - **password**: The password to use when connecting to the
* database.
* - **dbname**: The name of the Piwik MySQL database.
* - **port**: The MySQL database port to use.
* - **adapter**: either `'PDO_MYSQL'` or `'MYSQLI'`
*/
Piwik::postEvent('Reporting.getDatabaseConfig', array(&$dbInfos));
$dbInfos['profiler'] = $config->Debug['enable_sql_profiler'];
$adapter = $dbInfos['adapter'];
$db = @Adapter::factory($adapter, $dbInfos);
self::$connection = $db;
}
示例3: getErrorResponse
private static function getErrorResponse(Exception $ex)
{
$debugTrace = $ex->getTraceAsString();
$message = $ex->getMessage();
if (!method_exists($ex, 'isHtmlMessage') || !$ex->isHtmlMessage()) {
$message = Common::sanitizeInputValue($message);
}
$logo = new CustomLogo();
$logoHeaderUrl = false;
$logoFaviconUrl = false;
try {
$logoHeaderUrl = $logo->getHeaderLogoUrl();
$logoFaviconUrl = $logo->getPathUserFavicon();
} catch (Exception $ex) {
Log::debug($ex);
}
$result = Piwik_GetErrorMessagePage($message, $debugTrace, true, true, $logoHeaderUrl, $logoFaviconUrl);
/**
* Triggered before a Piwik error page is displayed to the user.
*
* This event can be used to modify the content of the error page that is displayed when
* an exception is caught.
*
* @param string &$result The HTML of the error page.
* @param Exception $ex The Exception displayed in the error page.
*/
Piwik::postEvent('FrontController.modifyErrorPage', array(&$result, $ex));
return $result;
}
示例4: getDatabaseConfig
public static function getDatabaseConfig($dbConfig = null)
{
$config = Config::getInstance();
if (is_null($dbConfig)) {
$dbConfig = $config->database;
}
/**
* Triggered before a database connection is established.
*
* This event can be used to change the settings used to establish a connection.
*
* @param array *$dbInfos Reference to an array containing database connection info,
* including:
*
* - **host**: The host name or IP address to the MySQL database.
* - **username**: The username to use when connecting to the
* database.
* - **password**: The password to use when connecting to the
* database.
* - **dbname**: The name of the Piwik MySQL database.
* - **port**: The MySQL database port to use.
* - **adapter**: either `'PDO\MYSQL'` or `'MYSQLI'`
* - **type**: The MySQL engine to use, for instance 'InnoDB'
*/
Piwik::postEvent('Db.getDatabaseConfig', array(&$dbConfig));
$dbConfig['profiler'] = @$config->Debug['enable_sql_profiler'];
return $dbConfig;
}
示例5: getAvailableLanguages
/**
* Return array of available languages
*
* @return array Arry of strings, each containing its ISO language code
*/
public function getAvailableLanguages()
{
if (!is_null($this->languageNames)) {
return $this->languageNames;
}
$path = PIWIK_INCLUDE_PATH . "/lang/";
$languagesPath = _glob($path . "*.json");
$pathLength = strlen($path);
$languages = array();
if ($languagesPath) {
foreach ($languagesPath as $language) {
$languages[] = substr($language, $pathLength, -strlen('.json'));
}
}
/**
* Hook called after loading available language files.
*
* Use this hook to customise the list of languagesPath available in Piwik.
*
* @param array
*/
Piwik::postEvent('LanguageManager.getAvailableLanguages', array(&$languages));
$this->languageNames = $languages;
return $languages;
}
示例6: getAvailableCommands
/**
* Returns a list of available command classnames.
*
* @return string[]
*/
private function getAvailableCommands()
{
$commands = $this->getDefaultPiwikCommands();
$detected = PluginManager::getInstance()->findMultipleComponents('Commands', 'Piwik\\Plugin\\ConsoleCommand');
$commands = array_merge($commands, $detected);
/**
* Triggered to filter / restrict console commands. Plugins that want to restrict commands
* should subscribe to this event and remove commands from the existing list.
*
* **Example**
*
* public function filterConsoleCommands(&$commands)
* {
* $key = array_search('Piwik\Plugins\MyPlugin\Commands\MyCommand', $commands);
* if (false !== $key) {
* unset($commands[$key]);
* }
* }
*
* @param array &$commands An array containing a list of command class names.
*/
Piwik::postEvent('Console.filterCommands', array(&$commands));
$commands = array_values(array_unique($commands));
return $commands;
}
示例7: retrieveFileLocations
protected function retrieveFileLocations()
{
/**
* Triggered when gathering the list of all stylesheets (CSS and LESS) needed by
* Piwik and its plugins.
*
* Plugins that have stylesheets should use this event to make those stylesheets
* load.
*
* Stylesheets should be placed within a **stylesheets** subdirectory in your plugin's
* root directory.
*
* _Note: While you are developing your plugin you should enable the config setting
* `[Debug] disable_merged_assets` so your stylesheets will be reloaded immediately
* after a change._
*
* **Example**
*
* public function getStylesheetFiles(&$stylesheets)
* {
* $stylesheets[] = "plugins/MyPlugin/stylesheets/myfile.less";
* $stylesheets[] = "plugins/MyPlugin/stylesheets/myotherfile.css";
* }
*
* @param string[] &$stylesheets The list of stylesheet paths.
*/
Piwik::postEvent('AssetManager.getStylesheetFiles', array(&$this->fileLocations));
$this->addThemeFiles();
}
示例8: retrieveFileLocations
protected function retrieveFileLocations()
{
if (!empty($this->plugins)) {
/**
* Triggered when gathering the list of all JavaScript files needed by Piwik
* and its plugins.
*
* Plugins that have their own JavaScript should use this event to make those
* files load in the browser.
*
* JavaScript files should be placed within a **javascripts** subdirectory in your
* plugin's root directory.
*
* _Note: While you are developing your plugin you should enable the config setting
* `[Development] disable_merged_assets` so JavaScript files will be reloaded immediately
* after every change._
*
* **Example**
*
* public function getJsFiles(&$jsFiles)
* {
* $jsFiles[] = "plugins/MyPlugin/javascripts/myfile.js";
* $jsFiles[] = "plugins/MyPlugin/javascripts/anotherone.js";
* }
*
* @param string[] $jsFiles The JavaScript files to load.
*/
Piwik::postEvent('AssetManager.getJavaScriptFiles', array(&$this->fileLocations), null, $this->plugins);
}
$this->addThemeFiles();
}
示例9: getWidgetConfigs
/**
* Get all existing widget configs.
*
* @return WidgetConfig[]
*/
public function getWidgetConfigs()
{
$widgetClasses = $this->getAllWidgetClassNames();
$configs = array();
/**
* Triggered to add custom widget configs. To filder widgets have a look at the {@hook Widget.filterWidgets}
* event.
*
* **Example**
*
* public function addWidgetConfigs(&$configs)
* {
* $config = new WidgetConfig();
* $config->setModule('PluginName');
* $config->setAction('renderDashboard');
* $config->setCategoryId('Dashboard_Dashboard');
* $config->setSubcategoryId('dashboardId');
* $configs[] = $config;
* }
*
* @param array &$configs An array containing a list of widget config entries.
*/
Piwik::postEvent('Widget.addWidgetConfigs', array(&$configs));
foreach ($widgetClasses as $widgetClass) {
$configs[] = $this->getWidgetConfigForClassName($widgetClass);
}
return $configs;
}
示例10: getMenu
/**
* Triggers the Menu.MenuAdmin.addItems hook and returns the admin menu.
*
* @return Array
*/
public function getMenu()
{
if (!$this->menu) {
/**
* Triggered when collecting all available admin menu items. Subscribe to this event if you want
* to add one or more items to the Piwik admin menu.
*
* Menu items should be added via the {@link add()} method.
*
* **Example**
*
* use Piwik\Menu\MenuAdmin;
*
* public function addMenuItems()
* {
* MenuAdmin::getInstance()->add(
* 'MenuName',
* 'SubmenuName',
* array('module' => 'MyPlugin', 'action' => 'index'),
* $showOnlyIf = Piwik::isUserIsSuperUser(),
* $order = 6
* );
* }
*/
Piwik::postEvent('Menu.Admin.addItems');
}
return parent::getMenu();
}
示例11: getInstance
/**
* Gets the singleton instance. Creates it if necessary.
*/
public static function getInstance()
{
if (self::$instance == null) {
self::$instance = new self();
Piwik::postEvent('Access.createAccessSingleton', array(&self::$instance));
}
return self::$instance;
}
示例12: collectTasksRegisteredViaEvent
private function collectTasksRegisteredViaEvent()
{
$tasks = array();
/**
* @ignore
*/
Piwik::postEvent(self::GET_TASKS_EVENT, array(&$tasks));
return $tasks;
}
示例13: makeSureTestRunsInContextOfAnonymousUser
private function makeSureTestRunsInContextOfAnonymousUser()
{
Piwik::postEvent('Request.initAuthenticationObject');
$access = Access::getInstance();
$this->hasSuperUserAccess = $access->hasSuperUserAccess();
$access->setSuperUserAccess(false);
$access->reloadAccess(StaticContainer::get('Piwik\\Auth'));
Request::reloadAuthUsingTokenAuth(array('token_auth' => 'anonymous'));
}
示例14: init
/**
* Initializes the kernel globals and DI container.
*/
public function init()
{
$this->invokeBeforeContainerCreatedHook();
$this->container = $this->createContainer();
StaticContainer::push($this->container);
$this->validateEnvironment();
$this->invokeEnvironmentBootstrappedHook();
Piwik::postEvent('Environment.bootstrapped');
// this event should be removed eventually
}
示例15: test_ScheduledReports_shouldRemoveOnlyReportsForGivenSitesAndLogin_IfEventIsTriggered
public function test_ScheduledReports_shouldRemoveOnlyReportsForGivenSitesAndLogin_IfEventIsTriggered()
{
Piwik::postEvent('UsersManager.removeSiteAccess', array('userLogin', array(1, 2)));
$this->assertHasNotReport('userlogin', 1);
$this->assertHasNotReport('userlogin', 2);
$this->assertHasReport('userlogin', 3);
$this->assertHasReport('userlogin', 4);
$this->assertHasReport('otherUser', 1);
$this->assertHasReport('anotherUser', 2);
}