本文整理汇总了PHP中Piwik\Plugin\Manager::activatePlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::activatePlugin方法的具体用法?PHP Manager::activatePlugin怎么用?PHP Manager::activatePlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Plugin\Manager
的用法示例。
在下文中一共展示了Manager::activatePlugin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_deactivatePlugin
public function test_deactivatePlugin()
{
$this->assertFalse($this->manager->isPluginActivated('ExampleTheme'));
$this->manager->activatePlugin('ExampleTheme');
$this->assertTrue($this->manager->isPluginActivated('ExampleTheme'));
$this->manager->deactivatePlugin('ExampleTheme');
$this->assertFalse($this->manager->isPluginActivated('ExampleTheme'));
}
示例2: activate
public function activate($redirectAfter = true)
{
$pluginName = $this->initPluginModification(static::ACTIVATE_NONCE);
$this->dieIfPluginsAdminIsDisabled();
$this->pluginManager->activatePlugin($pluginName);
if ($redirectAfter) {
$message = $this->translator->translate('CorePluginsAdmin_SuccessfullyActicated', array($pluginName));
if ($this->settingsProvider->getSystemSettings($pluginName)) {
$target = sprintf('<a href="index.php%s#%s">', Url::getCurrentQueryStringWithParametersModified(array('module' => 'CoreAdminHome', 'action' => 'generalSettings')), $pluginName);
$message .= ' ' . $this->translator->translate('CorePluginsAdmin_ChangeSettingsPossible', array($target, '</a>'));
}
$notification = new Notification($message);
$notification->raw = true;
$notification->title = $this->translator->translate('General_WellDone');
$notification->context = Notification::CONTEXT_SUCCESS;
Notification\Manager::notify('CorePluginsAdmin_PluginActivated', $notification);
$redirectTo = Common::getRequestVar('redirectTo', '', 'string');
if (!empty($redirectTo) && $redirectTo === 'marketplace') {
$this->redirectToIndex('Marketplace', 'overview');
} elseif (!empty($redirectTo) && $redirectTo === 'referrer') {
$this->redirectAfterModification($redirectAfter);
} else {
$plugin = $this->pluginManager->loadPlugin($pluginName);
$actionToRedirect = 'plugins';
if ($plugin->isTheme()) {
$actionToRedirect = 'themes';
}
$this->redirectToIndex('CorePluginsAdmin', $actionToRedirect);
}
}
}
示例3: installAllPaidPlugins
public function installAllPaidPlugins()
{
Piwik::checkUserHasSuperUserAccess();
$this->dieIfPluginsAdminIsDisabled();
Plugin\ControllerAdmin::displayWarningIfConfigFileNotWritable();
Nonce::checkNonce(static::INSTALL_NONCE);
$paidPlugins = $this->plugins->getAllPaidPlugins();
$hasErrors = false;
foreach ($paidPlugins as $paidPlugin) {
if (!$this->canPluginBeInstalled($paidPlugin)) {
continue;
}
$pluginName = $paidPlugin['name'];
try {
$this->pluginInstaller->installOrUpdatePluginFromMarketplace($pluginName);
} catch (\Exception $e) {
$notification = new Notification($e->getMessage());
$notification->context = Notification::CONTEXT_ERROR;
Notification\Manager::notify('Marketplace_Install' . $pluginName, $notification);
$hasErrors = true;
}
}
if ($hasErrors) {
Url::redirectToReferrer();
return;
}
$dependency = new Plugin\Dependency();
for ($i = 0; $i <= 10; $i++) {
foreach ($paidPlugins as $index => $paidPlugin) {
$pluginName = $paidPlugin['name'];
if ($this->pluginManager->isPluginActivated($pluginName)) {
unset($paidPlugins[$index]);
continue;
}
if (empty($paidPlugin['require']) || !$dependency->hasDependencyToDisabledPlugin($paidPlugin['require'])) {
unset($paidPlugins[$index]);
try {
$this->pluginManager->activatePlugin($pluginName);
} catch (Exception $e) {
$hasErrors = true;
$notification = new Notification($e->getMessage());
$notification->context = Notification::CONTEXT_ERROR;
Notification\Manager::notify('Marketplace_Install' . $pluginName, $notification);
}
}
}
}
if ($hasErrors) {
$notification = new Notification(Piwik::translate('Marketplace_OnlySomePaidPluginsInstalledAndActivated'));
$notification->context = Notification::CONTEXT_INFO;
} else {
$notification = new Notification(Piwik::translate('Marketplace_AllPaidPluginsInstalledAndActivated'));
$notification->context = Notification::CONTEXT_SUCCESS;
}
Notification\Manager::notify('Marketplace_InstallAll', $notification);
Url::redirectToReferrer();
}
示例4: exec
public function exec()
{
if (!$this->pluginManager->isPluginActivated($this->pluginName)) {
$this->pluginManager->activatePlugin($this->pluginName);
}
}