1 | <?php |
||
7 | class WorkflowFieldItemController extends Controller { |
||
|
|||
8 | |||
9 | public static $allowed_actions = array( |
||
10 | 'index', |
||
11 | 'edit', |
||
12 | 'delete', |
||
13 | 'Form' |
||
14 | ); |
||
15 | |||
16 | protected $parent; |
||
17 | protected $name; |
||
18 | |||
19 | public function __construct($parent, $name, $record) { |
||
20 | $this->parent = $parent; |
||
21 | $this->name = $name; |
||
22 | $this->record = $record; |
||
23 | |||
24 | parent::__construct(); |
||
25 | } |
||
26 | |||
27 | public function index() { |
||
30 | |||
31 | public function edit() { |
||
34 | |||
35 | public function Form() { |
||
36 | $record = $this->record; |
||
37 | $fields = $record->getCMSFields(); |
||
38 | $validator = $record->hasMethod('getValidator') ? $record->getValidator() : null; |
||
39 | |||
40 | $save = FormAction::create('doSave', _t('WorkflowReminderTask.SAVE', 'Save')); |
||
41 | $save->addExtraClass('ss-ui-button ss-ui-action-constructive') |
||
42 | ->setAttribute('data-icon', 'accept') |
||
43 | ->setUseButtonTag(true); |
||
44 | |||
45 | $form = new Form($this, 'Form', $fields, new FieldList($save), $validator); |
||
46 | if($record && $record instanceof DataObject && $record->exists()){ |
||
47 | $form->loadDataFrom($record); |
||
48 | } |
||
49 | return $form; |
||
50 | } |
||
51 | |||
52 | public function doSave($data, $form) { |
||
53 | $record = $form->getRecord(); |
||
54 | |||
55 | if(!$record || !$record->exists()){ |
||
56 | $record = $this->record; |
||
57 | } |
||
58 | |||
59 | if(!$record->canEdit()) { |
||
60 | $this->httpError(403); |
||
61 | } |
||
62 | |||
63 | if(!$record->isInDb()) { |
||
64 | $record->write(); |
||
65 | } |
||
66 | |||
67 | $form->saveInto($record); |
||
68 | $record->write(); |
||
69 | |||
70 | return $this->RootField()->forTemplate(); |
||
71 | } |
||
72 | |||
73 | public function delete($request) { |
||
89 | |||
90 | public function RootField() { |
||
93 | |||
94 | public function Link($action = null) { |
||
97 | |||
98 | } |
||
99 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.