Passed
Push — 4 ( 34eb17...84b405 )
by Robbie
08:27 queued 12s
created

DataExtension::updateCMSCompositeValidator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\ORM;
4
5
use SilverStripe\Core\Config\Config;
6
use SilverStripe\Core\Extension;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\CompositeValidator;
9
use SilverStripe\ORM\Queries\SQLSelect;
10
use Exception;
11
12
/**
13
 * An extension that adds additional functionality to a {@link DataObject}.
14
 *
15
 * @property DataObject $owner
16
 */
17
abstract class DataExtension extends Extension
18
{
19
20
    /**
21
     * @deprecated 4.7.0 No longer used by internal code
22
     */
23
    public static function unload_extra_statics($class, $extension)
0 ignored issues
show
Unused Code introduced by
The parameter $extension is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

23
    public static function unload_extra_statics($class, /** @scrutinizer ignore-unused */ $extension)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $class is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

23
    public static function unload_extra_statics(/** @scrutinizer ignore-unused */ $class, $extension)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
    {
25
        throw new Exception('unload_extra_statics gone');
26
    }
27
28
    /**
29
     * Hook for extension-specific validation.
30
     *
31
     * @param ValidationResult $validationResult Local validation result
32
     * @throws ValidationException
33
     */
34
    public function validate(ValidationResult $validationResult)
0 ignored issues
show
Unused Code introduced by
The parameter $validationResult is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

34
    public function validate(/** @scrutinizer ignore-unused */ ValidationResult $validationResult)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
    {
36
    }
37
38
    /**
39
     * Edit the given query object to support queries for this extension
40
     *
41
     * @param SQLSelect $query Query to augment.
42
     * @param DataQuery $dataQuery Container DataQuery for this SQLSelect
43
     */
44
    public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
0 ignored issues
show
Unused Code introduced by
The parameter $dataQuery is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

44
    public function augmentSQL(SQLSelect $query, /** @scrutinizer ignore-unused */ DataQuery $dataQuery = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $query is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

44
    public function augmentSQL(/** @scrutinizer ignore-unused */ SQLSelect $query, DataQuery $dataQuery = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46
    }
47
48
    /**
49
     * Update the database schema as required by this extension.
50
     *
51
     * When duplicating a table's structure, remember to duplicate the create options
52
     * as well. See {@link Versioned->augmentDatabase} for an example.
53
     */
54
    public function augmentDatabase()
55
    {
56
    }
57
58
    /**
59
     * Augment a write-record request.
60
     *
61
     * @param array $manipulation Array of operations to augment.
62
     */
63
    public function augmentWrite(&$manipulation)
0 ignored issues
show
Unused Code introduced by
The parameter $manipulation is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

63
    public function augmentWrite(/** @scrutinizer ignore-unused */ &$manipulation)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
    {
65
    }
66
67
    /**
68
     * Extend the owner's onBeforeWrite() logic
69
     *
70
     * See {@link DataObject::onBeforeWrite()} for context.
71
     */
72
    public function onBeforeWrite()
73
    {
74
    }
75
76
    /**
77
     * Extend the owner's onAfterWrite() logic
78
     *
79
     * See {@link DataObject::onAfterWrite()} for context.
80
     */
81
    public function onAfterWrite()
82
    {
83
    }
84
85
    /**
86
     * Extend the owner's onBeforeDelete() logic
87
     *
88
     * See {@link DataObject::onBeforeDelete()} for context.
89
     */
90
    public function onBeforeDelete()
91
    {
92
    }
93
94
    /**
95
     * Extend the owner's onAfterDelete() logic
96
     *
97
     * See {@link DataObject::onAfterDelete()} for context.
98
     */
99
    public function onAfterDelete()
100
    {
101
    }
102
103
    /**
104
     * Extend the owner's requireDefaultRecords() logic
105
     *
106
     * See {@link DataObject::requireDefaultRecords()} for context.
107
     */
108
    public function requireDefaultRecords()
109
    {
110
    }
111
112
    /**
113
     * Extend the owner's populateDefaults() logic
114
     *
115
     * See {@link DataObject::populateDefaults()} for context.
116
     */
117
    public function populateDefaults()
118
    {
119
    }
120
121
    /**
122
     * Extend the owner's onAfterBuild() logic
123
     *
124
     * See {@link DataObject::onAfterBuild()} for context.
125
     */
126
    public function onAfterBuild()
127
    {
128
    }
129
130
    /**
131
     * Influence the owner's can() permission check value to be disallowed (false),
132
     * allowed (true) if no other processed results are to disallow, or open (null) to not
133
     * affect the outcome.
134
     *
135
     * See {@link DataObject::can()} and {@link DataObject::extendedCan()} for context.
136
     *
137
     * @param Member $member
0 ignored issues
show
Bug introduced by
The type SilverStripe\ORM\Member was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
138
     * @param array $context
139
     * @return bool|null
140
     */
141
    public function can($member)
0 ignored issues
show
Unused Code introduced by
The parameter $member is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

141
    public function can(/** @scrutinizer ignore-unused */ $member)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
142
    {
143
    }
144
145
    /**
146
     * Influence the owner's canEdit() permission check value to be disallowed (false),
147
     * allowed (true) if no other processed results are to disallow, or open (null) to not
148
     * affect the outcome.
149
     *
150
     * See {@link DataObject::canEdit()} and {@link DataObject::extendedCan()} for context.
151
     *
152
     * @param Member $member
153
     * @param array $context
154
     * @return bool|null
155
     */
156
    public function canEdit($member)
0 ignored issues
show
Unused Code introduced by
The parameter $member is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

156
    public function canEdit(/** @scrutinizer ignore-unused */ $member)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
157
    {
158
    }
159
160
    /**
161
     * Influence the owner's canDelete() permission check value to be disallowed (false),
162
     * allowed (true) if no other processed results are to disallow, or open (null) to not
163
     * affect the outcome.
164
     *
165
     * See {@link DataObject::canDelete()} and {@link DataObject::extendedCan()} for context.
166
     *
167
     * @param Member $member
168
     * @param array $context
169
     * @return bool|null
170
     */
171
    public function canDelete($member)
0 ignored issues
show
Unused Code introduced by
The parameter $member is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

171
    public function canDelete(/** @scrutinizer ignore-unused */ $member)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
172
    {
173
    }
174
175
    /**
176
     * Influence the owner's canCreate() permission check value to be disallowed (false),
177
     * allowed (true) if no other processed results are to disallow, or open (null) to not
178
     * affect the outcome.
179
     *
180
     * See {@link DataObject::canCreate()} and {@link DataObject::extendedCan()} for context.
181
     *
182
     * @param Member $member
183
     * @param array $context
184
     * @return bool|null
185
     */
186
    public function canCreate($member)
0 ignored issues
show
Unused Code introduced by
The parameter $member is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

186
    public function canCreate(/** @scrutinizer ignore-unused */ $member)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
187
    {
188
    }
189
190
    /**
191
     * Define extra database fields
192
     *
193
     * Return a map where the keys are db, has_one, etc, and the values are
194
     * additional fields/relations to be defined.
195
     *
196
     * @param string $class since this method might be called on the class directly
197
     * @param string $extension since this can help to extract parameters to help set indexes
198
     * @return array Returns a map where the keys are db, has_one, etc, and
199
     *               the values are additional fields/relations to be defined.
200
     */
201
    public function extraStatics($class = null, $extension = null)
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

201
    public function extraStatics(/** @scrutinizer ignore-unused */ $class = null, $extension = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $extension is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

201
    public function extraStatics($class = null, /** @scrutinizer ignore-unused */ $extension = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
202
    {
203
        return [];
204
    }
205
206
    /**
207
     * This function is used to provide modifications to the form in the CMS
208
     * by the extension. By default, no changes are made. {@link DataObject->getCMSFields()}.
209
     *
210
     * Please consider using {@link updateFormFields()} to globally add
211
     * formfields to the record. The method {@link updateCMSFields()}
212
     * should just be used to add or modify tabs, or fields which
213
     * are specific to the CMS-context.
214
     *
215
     * Caution: Use {@link FieldList->addFieldToTab()} to add fields.
216
     *
217
     * @param FieldList $fields FieldList with a contained TabSet
218
     */
219
    public function updateCMSFields(FieldList $fields)
220
    {
221
    }
222
223
    /**
224
     * This function is used to provide modifications to the Validators used on a DataObject.
225
     *
226
     * Caution: Use {@link CompositeValidator->addValidator()} to add Validators.
227
     *
228
     * @param CompositeValidator $compositeValidator
229
     */
230
    public function updateCMSCompositeValidator(CompositeValidator $compositeValidator): void
0 ignored issues
show
Unused Code introduced by
The parameter $compositeValidator is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

230
    public function updateCMSCompositeValidator(/** @scrutinizer ignore-unused */ CompositeValidator $compositeValidator): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
231
    {
232
    }
233
234
    /**
235
     * This function is used to provide modifications to the form used
236
     * for front end forms. {@link DataObject->getFrontEndFields()}
237
     *
238
     * Caution: Use {@link FieldList->push()} to add fields.
239
     *
240
     * @param FieldList $fields FieldList without TabSet nesting
241
     */
242
    public function updateFrontEndFields(FieldList $fields)
0 ignored issues
show
Unused Code introduced by
The parameter $fields is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

242
    public function updateFrontEndFields(/** @scrutinizer ignore-unused */ FieldList $fields)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
243
    {
244
    }
245
246
    /**
247
     * This is used to provide modifications to the form actions
248
     * used in the CMS. {@link DataObject->getCMSActions()}.
249
     *
250
     * @param FieldList $actions FieldList
251
     */
252
    public function updateCMSActions(FieldList $actions)
0 ignored issues
show
Unused Code introduced by
The parameter $actions is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

252
    public function updateCMSActions(/** @scrutinizer ignore-unused */ FieldList $actions)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
253
    {
254
    }
255
256
    /**
257
     * this function is used to provide modifications to the summary fields in CMS
258
     * by the extension
259
     * By default, the summaryField() of its owner will merge more fields defined in the extension's
260
     * $extra_fields['summary_fields']
261
     *
262
     * @param array $fields Array of field names
263
     */
264
    public function updateSummaryFields(&$fields)
265
    {
266
        $summary_fields = Config::inst()->get(static::class, 'summary_fields');
267
        if ($summary_fields) {
268
            // if summary_fields were passed in numeric array,
269
            // convert to an associative array
270
            if ($summary_fields && array_key_exists(0, $summary_fields)) {
271
                $summary_fields = array_combine(array_values($summary_fields), array_values($summary_fields));
272
            }
273
            if ($summary_fields) {
274
                $fields = array_merge($fields, $summary_fields);
275
            }
276
        }
277
    }
278
279
    /**
280
     * this function is used to provide modifications to the fields labels in CMS
281
     * by the extension
282
     * By default, the fieldLabels() of its owner will merge more fields defined in the extension's
283
     * $extra_fields['field_labels']
284
     *
285
     * @param array $labels Array of field labels
286
     */
287
    public function updateFieldLabels(&$labels)
288
    {
289
        $field_labels = Config::inst()->get(static::class, 'field_labels');
290
        if ($field_labels) {
291
            $labels = array_merge($labels, $field_labels);
292
        }
293
    }
294
}
295