1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dynamic\Foxy\Model; |
4
|
|
|
|
5
|
|
|
use Dynamic\Products\Page\Product; |
|
|
|
|
6
|
|
|
use SilverStripe\Forms\FieldList; |
7
|
|
|
use SilverStripe\Forms\GridField\GridField; |
8
|
|
|
use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter; |
9
|
|
|
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; |
10
|
|
|
use SilverStripe\ORM\DataObject; |
11
|
|
|
use Symbiote\GridFieldExtensions\GridFieldAddExistingSearchButton; |
|
|
|
|
12
|
|
|
use Symbiote\GridFieldExtensions\GridFieldOrderableRows; |
|
|
|
|
13
|
|
|
|
14
|
|
|
class OptionType extends DataObject |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var array |
18
|
|
|
*/ |
19
|
|
|
private static $db = [ |
|
|
|
|
20
|
|
|
'Title' => 'Varchar(255)', |
21
|
|
|
'SortOrder' => 'Int', |
22
|
|
|
]; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var array |
26
|
|
|
*/ |
27
|
|
|
private static $many_many = [ |
|
|
|
|
28
|
|
|
'Options' => ProductOption::class, |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var array |
33
|
|
|
*/ |
34
|
|
|
private static $many_many_extraFields = [ |
|
|
|
|
35
|
|
|
'Options' => [ |
36
|
|
|
'WeightModifier' => 'Decimal', |
37
|
|
|
'CodeModifier' => 'Text', |
38
|
|
|
'PriceModifier' => 'Currency', |
39
|
|
|
'WeightModifierAction' => "Enum('Add,Subtract,Set', null)", |
40
|
|
|
'CodeModifierAction' => "Enum('Add,Subtract,Set', null)", |
41
|
|
|
'PriceModifierAction' => "Enum('Add,Subtract,Set', null)", |
42
|
|
|
'Available' => 'Boolean', |
43
|
|
|
'SortOrder' => 'Int', |
44
|
|
|
], |
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
private static $table_name = 'OptionType'; |
|
|
|
|
51
|
|
|
|
52
|
|
|
public function getCMSFields() |
53
|
|
|
{ |
54
|
|
|
$this->beforeUpdateCMSFields(function (FieldList $fields) { |
55
|
|
|
$fields->removeByName([ |
56
|
|
|
'SortOrder', |
57
|
|
|
'ProductID', |
58
|
|
|
'Options', |
59
|
|
|
]); |
60
|
|
|
|
61
|
|
|
if ($this->ID) { |
62
|
|
|
$config = GridFieldConfig_RelationEditor::create(); |
63
|
|
|
$config |
64
|
|
|
->addComponents([ |
65
|
|
|
new GridFieldAddExistingSearchButton(), |
66
|
|
|
new GridFieldOrderableRows('SortOrder'), |
67
|
|
|
]) |
68
|
|
|
->removeComponentsByType([ |
69
|
|
|
GridFieldAddExistingAutocompleter::class, |
70
|
|
|
]); |
71
|
|
|
$options = GridField::create( |
72
|
|
|
'Options', |
73
|
|
|
'Options', |
74
|
|
|
$this->owner->Options()->sort('SortOrder'), |
|
|
|
|
75
|
|
|
$config |
76
|
|
|
); |
77
|
|
|
$fields->addFieldToTab('Root.Main', $options); |
78
|
|
|
} |
79
|
|
|
}); |
80
|
|
|
|
81
|
|
|
return parent::getCMSFields(); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
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