nystudio107 /
craft-retour
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Retour plugin for Craft CMS |
||
| 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/ |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 9 | * @copyright Copyright (c) 2021 nystudio107 |
||
|
0 ignored issues
–
show
|
|||
| 10 | */ |
||
|
0 ignored issues
–
show
|
|||
| 11 | |||
| 12 | namespace nystudio107\retour\helpers; |
||
| 13 | |||
| 14 | use Composer\Semver\Semver; |
||
| 15 | use Craft; |
||
| 16 | use Jean85\PrettyVersions; |
||
| 17 | use Throwable; |
||
| 18 | |||
| 19 | /** |
||
|
0 ignored issues
–
show
|
|||
| 20 | * @author nystudio107 |
||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||
| 21 | * @package Retour |
||
|
0 ignored issues
–
show
|
|||
| 22 | * @since 3.1.48 |
||
|
0 ignored issues
–
show
|
|||
| 23 | */ |
||
|
0 ignored issues
–
show
|
|||
| 24 | class Version |
||
| 25 | { |
||
| 26 | // Constants |
||
| 27 | // ========================================================================= |
||
| 28 | |||
| 29 | protected const LEAGUE_CSV_PACKAGE = 'league/csv'; |
||
| 30 | |||
| 31 | // Public Static Methods |
||
| 32 | // ========================================================================= |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Return the API version for `league/csv` package |
||
| 36 | * |
||
| 37 | * @return int API version (or 0 for not installed) |
||
| 38 | */ |
||
| 39 | public static function getLeagueCsvVersion(): int |
||
| 40 | { |
||
| 41 | $version = 0; |
||
| 42 | $installedVersion = null; |
||
| 43 | try { |
||
| 44 | $pv = PrettyVersions::getVersion(self::LEAGUE_CSV_PACKAGE); |
||
| 45 | $installedVersion = $pv->getPrettyVersion(); |
||
| 46 | } catch (Throwable $e) { |
||
| 47 | Craft::error($e, __METHOD__); |
||
| 48 | } |
||
| 49 | if ($installedVersion) { |
||
| 50 | if (Semver::satisfies($installedVersion, '^8.0.0')) { |
||
| 51 | $version = 8; |
||
| 52 | } |
||
| 53 | if (Semver::satisfies($installedVersion, '^9.0.0')) { |
||
| 54 | $version = 9; |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | return $version; |
||
| 59 | } |
||
| 60 | } |
||
| 61 |