本文整理匯總了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);
}
}