1 | <?php |
||
2 | |||
3 | namespace BringYourOwnIdeas\UpdateChecker\Extensions; |
||
4 | |||
5 | use SilverStripe\ORM\DataExtension; |
||
6 | |||
7 | /** |
||
8 | * Describes any available updates to an installed Composer package |
||
9 | * |
||
10 | * Originally from https://github.com/XploreNet/silverstripe-composerupdates |
||
11 | */ |
||
12 | class ComposerUpdateExtension extends DataExtension |
||
13 | { |
||
14 | private static $db = [ |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
15 | 'VersionHash' => 'Varchar', |
||
16 | 'VersionConstraint' => 'Varchar(50)', |
||
17 | 'AvailableVersion' => 'Varchar(50)', |
||
18 | 'AvailableHash' => 'Varchar(50)', |
||
19 | 'LatestVersion' => 'Varchar(50)', |
||
20 | 'LatestHash' => 'Varchar(50)', |
||
21 | ]; |
||
22 | |||
23 | private static $summary_fields = [ |
||
0 ignored issues
–
show
|
|||
24 | 'AvailableVersion' => 'Available', |
||
25 | 'LatestVersion' => 'Latest', |
||
26 | ]; |
||
27 | |||
28 | /** |
||
29 | * If the available version is the same as the current version then return nothing, otherwise show the latest |
||
30 | * available version |
||
31 | * |
||
32 | * @return string |
||
33 | */ |
||
34 | public function getAvailableVersion() |
||
35 | { |
||
36 | if ($this->owner->getField('Version') === $this->owner->getField('AvailableVersion')) { |
||
37 | return ''; |
||
38 | } |
||
39 | return $this->owner->getField('AvailableVersion'); |
||
40 | } |
||
41 | } |
||
42 |