1 | <?php |
||
2 | /** |
||
3 | * Retour plugin for Craft CMS 3.x |
||
4 | * |
||
5 | * Retour allows you to intelligently redirect legacy URLs, so that you don't |
||
6 | * lose SEO value when rebuilding & restructuring a website |
||
7 | * |
||
8 | * @link https://nystudio107.com/ |
||
9 | * @copyright Copyright (c) 2021 nystudio107 |
||
10 | */ |
||
11 | |||
12 | namespace nystudio107\retour\helpers; |
||
13 | |||
14 | use Jean85\PrettyVersions; |
||
15 | |||
16 | use \Composer\Semver\Semver; |
||
17 | |||
18 | /** |
||
19 | * @author nystudio107 |
||
20 | * @package Retour |
||
21 | * @since 3.1.48 |
||
22 | */ |
||
23 | class Version |
||
24 | { |
||
25 | // Constants |
||
26 | // ========================================================================= |
||
27 | |||
28 | const LEAGUE_CSV_PACKAGE = 'league/csv'; |
||
29 | |||
30 | // Public Static Methods |
||
31 | // ========================================================================= |
||
32 | |||
33 | /** |
||
34 | * Return the API version for `league/csv` package |
||
35 | * |
||
36 | * @return int API version (or 0 for not installed) |
||
37 | */ |
||
38 | public static function getLeagueCsvVersion(): int |
||
39 | { |
||
40 | $version = 0; |
||
41 | $installedVersion = null; |
||
42 | try { |
||
43 | $pv = PrettyVersions::getVersion(self::LEAGUE_CSV_PACKAGE); |
||
44 | $installedVersion = $pv->getPrettyVersion(); |
||
45 | } catch (\Throwable $e) { |
||
46 | Craft::error($e, __METHOD__); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
47 | } |
||
48 | if ($installedVersion) { |
||
49 | if (Semver::satisfies($installedVersion, '^8.0.0')) { |
||
50 | $version = 8; |
||
51 | } |
||
52 | if (Semver::satisfies($installedVersion, '^9.0.0')) { |
||
53 | $version = 9; |
||
54 | } |
||
55 | } |
||
56 | |||
57 | return $version; |
||
58 | } |
||
59 | } |
||
60 |