コード例 #1
0
 /**
  * Removes and packs down a plugin from the system. Files are left intact.
  */
 public function removePlugin($plugin)
 {
     $code = is_string($plugin) ? $plugin : $this->pluginManager->getIdentifier($plugin);
     if (!$this->hasVersionFile($code)) {
         return false;
     }
     $pluginHistory = $this->getDatabaseHistory($code);
     $pluginHistory = array_reverse($pluginHistory);
     foreach ($pluginHistory as $history) {
         if ($history->type == self::HISTORY_TYPE_COMMENT) {
             $this->removeDatabaseComment($code, $history->version);
         } elseif ($history->type == self::HISTORY_TYPE_SCRIPT) {
             $this->removeDatabaseScript($code, $history->version, $history->detail);
         }
     }
     $this->setDatabaseVersion($code);
     if (isset($this->fileVersions[$code])) {
         unset($this->fileVersions[$code]);
     }
     if (isset($this->databaseVersions[$code])) {
         unset($this->databaseVersions[$code]);
     }
     if (isset($this->databaseHistory[$code])) {
         unset($this->databaseHistory[$code]);
     }
     return true;
 }
コード例 #2
0
 /**
  * Removes and packs down a plugin from the system. Files are left intact.
  * If the $stopOnVersion parameter is specified, the process stops after
  * the specified version is rolled back.
  */
 public function removePlugin($plugin, $stopOnVersion = null)
 {
     $code = is_string($plugin) ? $plugin : $this->pluginManager->getIdentifier($plugin);
     if (!$this->hasVersionFile($code)) {
         return false;
     }
     $pluginHistory = $this->getDatabaseHistory($code);
     $pluginHistory = array_reverse($pluginHistory);
     $stopOnNextVersion = false;
     $newPluginVersion = null;
     foreach ($pluginHistory as $history) {
         if ($stopOnNextVersion && $history->version !== $stopOnVersion) {
             // Stop if the $stopOnVersion value was found and
             // this is a new version. The history could contain
             // multiple items for a single version (comments and scripts).
             $newPluginVersion = $history->version;
             break;
         }
         if ($history->type == self::HISTORY_TYPE_COMMENT) {
             $this->removeDatabaseComment($code, $history->version);
         } elseif ($history->type == self::HISTORY_TYPE_SCRIPT) {
             $this->removeDatabaseScript($code, $history->version, $history->detail);
         }
         if ($stopOnVersion === $history->version) {
             $stopOnNextVersion = true;
         }
     }
     $this->setDatabaseVersion($code, $newPluginVersion);
     if (isset($this->fileVersions[$code])) {
         unset($this->fileVersions[$code]);
     }
     if (isset($this->databaseVersions[$code])) {
         unset($this->databaseVersions[$code]);
     }
     if (isset($this->databaseHistory[$code])) {
         unset($this->databaseHistory[$code]);
     }
     return true;
 }