Piwik\Plugins\Marketplace\Api\Client::getInfoOfPluginsHavingUpdate PHP Метод

getInfoOfPluginsHavingUpdate() публичный Метод

public getInfoOfPluginsHavingUpdate ( Plugin[] $plugins ) : array
$plugins Piwik\Plugin[]
Результат array
    public function getInfoOfPluginsHavingUpdate($plugins)
    {
        $hasUpdates = $this->checkUpdates($plugins);
        $pluginDetails = array();
        foreach ($hasUpdates as $pluginHavingUpdate) {
            if (empty($pluginHavingUpdate)) {
                continue;
            }
            try {
                $plugin = $this->getPluginInfo($pluginHavingUpdate['name']);
            } catch (PhpException $e) {
                $this->logger->error($e->getMessage());
                $plugin = null;
            }
            if (!empty($plugin)) {
                $plugin['repositoryChangelogUrl'] = $pluginHavingUpdate['repositoryChangelogUrl'];
                $pluginDetails[] = $plugin;
            }
        }
        return $pluginDetails;
    }

Usage Example

Пример #1
0
 /**
  * @param bool $themesOnly
  * @return array
  */
 public function getPluginsHavingUpdate()
 {
     $this->pluginManager->loadAllPluginsAndGetTheirInfo();
     $loadedPlugins = $this->pluginManager->getLoadedPlugins();
     try {
         $pluginsHavingUpdate = $this->marketplaceClient->getInfoOfPluginsHavingUpdate($loadedPlugins);
     } catch (\Exception $e) {
         $pluginsHavingUpdate = array();
     }
     foreach ($pluginsHavingUpdate as $key => $updatePlugin) {
         foreach ($loadedPlugins as $loadedPlugin) {
             if (!empty($updatePlugin['name']) && $loadedPlugin->getPluginName() == $updatePlugin['name']) {
                 $updatePlugin['currentVersion'] = $loadedPlugin->getVersion();
                 $updatePlugin['isActivated'] = $this->pluginManager->isPluginActivated($updatePlugin['name']);
                 $pluginsHavingUpdate[$key] = $this->addMissingRequirements($updatePlugin);
                 break;
             }
         }
     }
     // remove plugins that have updates but for some reason are not loaded
     foreach ($pluginsHavingUpdate as $key => $updatePlugin) {
         if (empty($updatePlugin['currentVersion'])) {
             unset($pluginsHavingUpdate[$key]);
         }
     }
     return $pluginsHavingUpdate;
 }