1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dyanmic\Salsify\ORM; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Admin\LeftAndMain; |
|
|
|
|
6
|
|
|
use SilverStripe\CMS\Model\SiteTree; |
|
|
|
|
7
|
|
|
use SilverStripe\Control\Controller; |
8
|
|
|
use SilverStripe\Forms\DatetimeField; |
9
|
|
|
use SilverStripe\Forms\FieldList; |
10
|
|
|
use SilverStripe\Forms\FormAction; |
11
|
|
|
use SilverStripe\Forms\TextField; |
12
|
|
|
use SilverStripe\ORM\DataExtension; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class FileExtension |
16
|
|
|
* |
17
|
|
|
* @property string SalsifyID |
18
|
|
|
* @property string SalsifyUpdatedAt |
19
|
|
|
* |
20
|
|
|
* @property-read \SilverStripe\ORM\DataObject|\Dyanmic\Salsify\ORM\SalsifyIDExtension $owner |
21
|
|
|
*/ |
22
|
|
|
class SalsifyIDExtension extends DataExtension |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
private static $db = [ |
|
|
|
|
29
|
|
|
'SalsifyID' => 'Varchar(255)', |
30
|
|
|
'SalsifyUpdatedAt' => 'Varchar(255)' |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param \SilverStripe\Forms\FieldList $fields |
35
|
|
|
*/ |
36
|
|
|
protected function updateFields(FieldList $fields) |
37
|
|
|
{ |
38
|
|
|
$salsifyID = $fields->dataFieldByName('SalsifyID'); |
39
|
|
|
if (!$salsifyID) { |
|
|
|
|
40
|
|
|
$fields->push($salsifyID = TextField::create('SalsifyID')); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$salsifyUpdatedAt = $fields->dataFieldByName('SalsifyUpdatedAt'); |
44
|
|
|
if (!$salsifyUpdatedAt) { |
|
|
|
|
45
|
|
|
$fields->push($salsifyUpdatedAt = DatetimeField::create('SalsifyUpdatedAt')); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
if ($this->owner->SalsifyID) { |
49
|
|
|
$salsifyID->setReadonly(true); |
50
|
|
|
} |
51
|
|
|
$salsifyUpdatedAt->setReadonly(true); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param \SilverStripe\Forms\FieldList $fields |
56
|
|
|
*/ |
57
|
|
|
public function updateCMSFields(FieldList $fields) |
58
|
|
|
{ |
59
|
|
|
if ($this->owner instanceof SiteTree) { |
60
|
|
|
return parent::updateCMSFields($fields); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$this->updateFields($fields); |
64
|
|
|
return parent::updateCMSFields($fields); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param \SilverStripe\Forms\FieldList $fields |
69
|
|
|
*/ |
70
|
|
|
public function updateSettingsFields(FieldList $fields) { |
71
|
|
|
$this->updateFields($fields); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param \SilverStripe\Forms\FieldList $actions |
76
|
|
|
*/ |
77
|
|
|
public function updateCMSActions(FieldList $actions) |
78
|
|
|
{ |
79
|
|
|
parent::updateCMSActions($actions); |
80
|
|
|
|
81
|
|
|
if (!$this->owner->SalsifyID) { |
82
|
|
|
return; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
$controller = Controller::curr(); |
86
|
|
|
if ($controller instanceof LeftAndMain && $controller->canFetchSalsify()) { |
87
|
|
|
/** @var FormAction $action */ |
88
|
|
|
$action = FormAction::create('salsifyFetch', 'Re-fetch Salsify') |
89
|
|
|
->addExtraClass('btn-primary font-icon-sync') |
90
|
|
|
->setUseButtonTag(true); |
91
|
|
|
|
92
|
|
|
$actions->push($action); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
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