|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace BringYourOwnIdeas\Maintenance\Model; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Core\Injector\Injector; |
|
6
|
|
|
use BringYourOwnIdeas\Maintenance\Tasks\UpdatePackageInfoTask; |
|
7
|
|
|
use SilverStripe\ORM\DataObject; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Describes an installed composer package version. |
|
11
|
|
|
*/ |
|
12
|
|
|
class Package extends DataObject |
|
13
|
|
|
{ |
|
14
|
|
|
private static $table_name = 'Package'; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
private static $db = [ |
|
|
|
|
|
|
17
|
|
|
'Name' => 'Varchar(255)', |
|
18
|
|
|
'Description' => 'Varchar(255)', |
|
19
|
|
|
'Version' => 'Varchar(255)', |
|
20
|
|
|
'Type' => 'Varchar(255)', |
|
21
|
|
|
'Supported' => 'Boolean', |
|
22
|
|
|
]; |
|
23
|
|
|
|
|
24
|
|
|
private static $summary_fields = [ |
|
|
|
|
|
|
25
|
|
|
'Title' => 'Title', |
|
26
|
|
|
'Description' => 'Description', |
|
27
|
|
|
'Version' => 'Version', |
|
28
|
|
|
]; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Strips vendor and 'silverstripe-' prefix from Name property |
|
32
|
|
|
* @return string More easily digestable module name for human consumers |
|
33
|
|
|
*/ |
|
34
|
|
|
public function getTitle() |
|
35
|
|
|
{ |
|
36
|
|
|
return preg_replace('#^[^/]+/(silverstripe-)?#', '', $this->Name); |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Returns HTML formatted summary of this object, uses a template to do this. |
|
41
|
|
|
* @return string |
|
42
|
|
|
*/ |
|
43
|
|
|
public function getSummary() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->renderWith('Package_summary'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* requireDefaultRecords() gets abused to update the information on dev/build. |
|
50
|
|
|
*/ |
|
51
|
|
|
public function requireDefaultRecords() |
|
52
|
|
|
{ |
|
53
|
|
|
parent::requireDefaultRecords(); |
|
54
|
|
|
$task = Injector::inst()->create(UpdatePackageInfoTask::class); |
|
55
|
|
|
$task->run(null); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|