Components_Component::getPreviousVersion PHP Method

getPreviousVersion() public method

Returns the previous version of the component.
public getPreviousVersion ( ) : string
return string The previous component version.
    public function getPreviousVersion();

Usage Example

Ejemplo n.º 1
0
    /**
     * Populates the release information for the current component.
     */
    protected function _setReleaseNotes()
    {
        if (!($file = $this->_component->getReleaseNotesPath())) {
            return;
        }
        if (basename($file) == 'release.yml') {
            $version = Components_Helper_Version::parsePearVersion($this->_component->getVersion());
            $description = Horde_String::lower($version->description);
            if (strpos($description, 'release') === false) {
                $description .= ' release';
            }
            $infofile = dirname($file) . '/horde.yml';
            try {
                $info = Horde_Yaml::loadFile($infofile);
            } catch (Horde_Yaml_Exception $e) {
                throw new Components_Exception($e);
            }
            $this->_notes['name'] = $info['name'];
            if (isset($info['list'])) {
                $this->_notes['list'] = $info['list'];
            }
            try {
                $release = Horde_Yaml::loadFile($file);
            } catch (Horde_Yaml_Exception $e) {
                throw new Components_Exception($e);
            }
            if (isset($release['branch'])) {
                $this->_notes['branch'] = $release['branch'];
            }
            $this->_notes['security'] = $release['security'];
            if (is_array($release['changes'])) {
                if (!is_array(reset($release['changes']))) {
                    $release['changes'] = array($release['changes']);
                }
            } else {
                $release['changes'] = array();
            }
            $currentSection = null;
            $changes = '';
            foreach ($release['changes'] as $section => $sectionChanges) {
                if ($section != $currentSection) {
                    $changes .= "\n\n" . $section . ':';
                    $currentSection = $section;
                }
                foreach ($sectionChanges as $change) {
                    $changes .= "\n    * " . $change;
                }
            }
            switch ($version->description) {
                case 'Final':
                    $prerelease = '';
                    break;
                case 'Alpha':
                case 'Beta':
                    $prerelease = '
This is a preview version that should not be used on production systems. This version is considered feature complete but there might still be a few bugs. You should not use this preview version over existing production data.

We encourage widespread testing and feedback via the mailing lists or our bug tracking system. Updated translations are very welcome, though some strings might still change before the final release.
';
                    break;
                case 'Release Candidate':
                    $prerelease = sprintf('
Barring any problems, this code will be released as %s %s.
Testing is requested and comments are encouraged. Updated translations would also be great.
', $info['name'], $version->version);
                    break;
            }
            $this->_notes['changes'] = sprintf('The Horde Team is pleased to announce the %s%s of the %s version %s.

%s
%s
For upgrading instructions, please see
http://www.horde.org/apps/%s/docs/UPGRADING

For detailed installation and configuration instructions, please see
http://www.horde.org/apps/%s/docs/INSTALL
%s
The major changes compared to the %s version %s are:%s', $version->subversion ? NumberFormatter::create('en_US', NumberFormatter::ORDINAL)->format($version->subversion) . ' ' : '', $description, $info['full'], $version->version, $info['description'], $prerelease, $info['id'], $info['id'], !empty($release['additional']) ? "\n" . implode("\n\n", $release['additional']) . "\n" : '', $info['name'], $this->_component->getPreviousVersion(), $changes);
        } else {
            $this->_notes = (include $file);
        }
    }