Skip to content

Commit ced8fdf

Browse files
committed
Added version ordering config option
1 parent f2c976f commit ced8fdf

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

app/config/codex.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@
3636

3737
'default_manual' => '',
3838

39+
/*
40+
|--------------------------------------------------------------------------
41+
| Version Ordering
42+
|--------------------------------------------------------------------------
43+
|
44+
| Allows you to define if you wish the versions be ordered by numerics
45+
| first (1, 2, 3, a, b, c), or alphabetically (a, b, c, 1, 2, 3).
46+
|
47+
| Supported: "numerical", "alphabetically"
48+
|
49+
*/
50+
51+
'version_ordering' => 'numerical',
52+
3953
/*
4054
|--------------------------------------------------------------------------
4155
| Google Analytics Tracking Code

app/repositories/CodexRepositoryFlat.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,16 @@ public function getDefaultVersion($manual)
157157
{
158158
$versions = $this->getVersions($manual);
159159

160-
return strval(max($versions));
160+
switch ($this->config->get('codex.version_ordering')) {
161+
case 'numerical':
162+
sort($versions, SORT_NATURAL);
163+
break;
164+
case 'alphabetically':
165+
sort($versions, SORT_NUMERIC);
166+
break;
167+
}
168+
169+
return $versions[0];
161170
}
162171

163172
/**

app/repositories/CodexRepositoryGit.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,16 @@ public function getDefaultVersion($manual)
182182
{
183183
$versions = $this->getVersions($manual);
184184

185-
return strval(max($versions));
185+
switch ($this->config->get('codex.version_ordering')) {
186+
case 'numerical':
187+
sort($versions, SORT_NATURAL);
188+
break;
189+
case 'alphabetically':
190+
sort($versions, SORT_NUMERIC);
191+
break;
192+
}
193+
194+
return $versions[0];
186195
}
187196

188197
/**

0 commit comments

Comments
 (0)