Commit 3cca5b02 authored by Thomas Löffler's avatar Thomas Löffler

Changes the order of releases and download numbers

parent 67a448d7
Pipeline #1813 passed with stages
in 3 minutes and 3 seconds
......@@ -326,17 +326,25 @@ class Extension extends \T3o\TerFe2\Domain\Model\AbstractEntity
/**
* Get versions reverse sorted by version number
*
* @param int $limit
* @param bool $reverseAfterSlice
* @return array|\T3o\TerFe2\Domain\Model\Version[] Versions
*/
public function getReverseVersionsByVersionNumber()
public function getReverseVersionsByVersionNumber($limit = 0, $reverseAfterSlice = true)
{
$versions = array();
foreach ($this->versions as $version) {
$versions[$version->getVersionNumber()] = $version;
}
krsort($versions);
if ($limit > 0) {
$versions = array_slice($versions, 0, $limit, true);
if ($reverseAfterSlice) {
$versions = array_reverse($versions);
}
}
return $versions;
}
......@@ -675,15 +683,12 @@ class Extension extends \T3o\TerFe2\Domain\Model\AbstractEntity
return '';
}
$versions = [];
foreach ($this->versions as $version) {
foreach ($this->getReverseVersionsByVersionNumber($versionCount) as $version) {
/** @var \T3o\TerFe2\Domain\Model\Version $version */
$versions['release'][$version->getUploadDate()] = date('d-m-Y', $version->getUploadDate());
$versions['versions'][] = $version->getVersionString();
$versions['downloads'][] = $version->getAllDownloads();
}
ksort($versions['release']);
sort($versions['versions']);
sort($versions['downloads']);
$versions['release'] = array_splice($versions['release'], $versionCount * -1);
$versions['versions'] = array_splice($versions['versions'], $versionCount * -1);
$versions['downloads'] = array_splice($versions['downloads'], $versionCount * -1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment