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