extensionsManager = $extensionsManager; $this->extensionHelper = $extensionHelper; } public function compare(Version $a, Version $b) : int { $merged = array_merge( $this->extensionsManager->getInstalledExtensions(), $this->getMissingExtensions() ); $sortedExtensions = array_flip(array_keys($this->extensionHelper::sortByDependencies($merged))); $versionA = (string) $a; $versionB = (string) $b; preg_match('/.*Version(\d+)_(.*)$/', $versionA, $matchesA); preg_match('/.*Version(\d+)_(.*)$/', $versionB, $matchesB); list($aClass, $aTime, $aExt) = $matchesA; list($bClass, $bTime, $bExt) = $matchesB; if ($aExt === $bExt) { return ((int) $aTime) - ((int) $bTime); } return $sortedExtensions[$aExt] - $sortedExtensions[$bExt]; } /** * @return Extension[] */ protected function getMissingExtensions() { $result = []; foreach ($this->extensionHelper::getMissingExtensionIds($this->extensionsManager->getInstalledExtensions()) as $extId) { $result[$extId] = $this->extensionsManager->getExtensionById($extId); } return $result; } }