FOF30\Update\Joomla::filterApplicableUpdates PHP Метод

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

Filters a list of updates, making sure they apply to the specifed CMS release.
public filterApplicableUpdates ( array $updates, string $jVersion = null ) : array
$updates array A list of update records returned by the getUpdatesFromExtension method
$jVersion string The current Joomla! version number
Результат array A filtered list of updates. Each update record also includes version relevance information.
    public function filterApplicableUpdates($updates, $jVersion = null)
    {
        if (empty($jVersion)) {
            $jVersion = JVERSION;
        }
        $versionParts = explode('.', $jVersion, 4);
        $platformVersionMajor = $versionParts[0];
        $platformVersionMinor = $platformVersionMajor . '.' . $versionParts[1];
        //$platformVersionNormal = $platformVersionMinor . '.' . $versionParts[2];
        //$platformVersionFull   = (count($versionParts) > 3) ? $platformVersionNormal . '.' . $versionParts[3] : $platformVersionNormal;
        $ret = array();
        foreach ($updates as $update) {
            // Check each update for platform match
            if (strtolower($update['targetplatform']['name']) != 'joomla') {
                continue;
            }
            $targetPlatformVersion = $update['targetplatform']['version'];
            if (!preg_match('/' . $targetPlatformVersion . '/', $platformVersionMinor)) {
                continue;
            }
            // Get some information from the version number
            $updateVersion = $update['version'];
            $versionProperties = $this->getVersionProperties($updateVersion, $jVersion);
            if ($versionProperties['upgrade'] == 'none') {
                continue;
            }
            // The XML files are ill-maintained. Maybe we already have this update?
            if (!array_key_exists($updateVersion, $ret)) {
                $ret[$updateVersion] = array_merge($update, $versionProperties);
            }
        }
        return $ret;
    }