1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dyanmic\Salsify\ORM; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Admin\LeftAndMain; |
|
|
|
|
6
|
|
|
use SilverStripe\Control\Controller; |
7
|
|
|
use SilverStripe\Forms\FieldList; |
8
|
|
|
use SilverStripe\Forms\FormAction; |
9
|
|
|
use SilverStripe\Forms\TextField; |
10
|
|
|
use SilverStripe\ORM\DataExtension; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class FileExtension |
14
|
|
|
* |
15
|
|
|
* @property string SalsifyID |
16
|
|
|
* @property string SalsifyUpdatedAt |
17
|
|
|
* |
18
|
|
|
* @property-read \SilverStripe\ORM\DataObject|\Dyanmic\Salsify\ORM\SalsifyIDExtension $owner |
19
|
|
|
*/ |
20
|
|
|
class SalsifyIDExtension extends DataExtension |
21
|
|
|
{ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
private static $db = [ |
|
|
|
|
27
|
|
|
'SalsifyID' => 'Varchar(255)', |
28
|
|
|
'SalsifyUpdatedAt' => 'Varchar(255)' |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param \SilverStripe\Forms\FieldList $fields |
33
|
|
|
*/ |
34
|
|
|
public function updateCMSFields(FieldList $fields) |
35
|
|
|
{ |
36
|
|
|
$salsifyID = $fields->dataFieldByName('SalsifyID'); |
37
|
|
|
if (!$salsifyID) { |
|
|
|
|
38
|
|
|
$fields->push($salsifyID = TextField::create('SalsifyID')); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$salsifyUpdatedAt = $fields->dataFieldByName('SalsifyUpdatedAt'); |
42
|
|
|
if (!$salsifyUpdatedAt) { |
|
|
|
|
43
|
|
|
$fields->push($salsifyUpdatedAt = TextField::create('SalsifyUpdatedAt')); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if ($this->owner->SalsifyID) { |
47
|
|
|
$salsifyID->setReadonly(true); |
48
|
|
|
} |
49
|
|
|
$salsifyUpdatedAt->setReadonly(true); |
50
|
|
|
|
51
|
|
|
return parent::updateCMSFields($fields); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param \SilverStripe\Forms\FieldList $actions |
56
|
|
|
*/ |
57
|
|
|
public function updateCMSActions(FieldList $actions) |
58
|
|
|
{ |
59
|
|
|
parent::updateCMSActions($actions); |
60
|
|
|
|
61
|
|
|
if (!$this->owner->SalsifyID) { |
62
|
|
|
return; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$controller = Controller::curr(); |
66
|
|
|
if ($controller instanceof LeftAndMain && $controller->canFetchSalsify()) { |
67
|
|
|
/** @var FormAction $action */ |
68
|
|
|
$action = FormAction::create('salsifyFetch', 'Re-fetch Salsify') |
69
|
|
|
->addExtraClass('btn-primary font-icon-sync') |
70
|
|
|
->setUseButtonTag(true); |
71
|
|
|
|
72
|
|
|
$actions->push($action); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths