Passed
Push — master ( 613a21...fb8a8c )
by Matthew
04:23
created

LocatorControllerExtension::setFormSchema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dynamic\Locator\React\Extensions;
4
5
use Dynamic\SilverStripeGeocoder\GoogleGeocoder;
6
use SilverStripe\Admin\LeftAndMain;
7
use SilverStripe\Control\Director;
8
use SilverStripe\Control\HTTPResponse;
9
use SilverStripe\Core\Config\Config;
10
use SilverStripe\Core\Convert;
11
use SilverStripe\Core\Extension;
12
use SilverStripe\Core\Injector\Injector;
13
use SilverStripe\Core\Manifest\ModuleResourceLoader;
14
use SilverStripe\Forms\Schema\FormSchema;
15
use SilverStripe\Security\SecurityToken;
16
use SilverStripe\View\Requirements;
17
18
/**
19
 * Class LocatorControllerExtension
20
 * @package Dynamic\Locator\React\Extensions
21
 *
22
 * @property \Dynamic\Locator\LocatorController|LocatorControllerExtension|LocatorExtension $owner
23
 */
24
class LocatorControllerExtension extends Extension
25
{
26
27
    /**
28
     * @var array
29
     */
30
    private static $allowed_actions = [
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
31
        'schema',
32
    ];
33
34
    /**
35
     * @var array
36
     */
37
    private static $dependencies = [
0 ignored issues
show
introduced by
The private property $dependencies is not used, and could be removed.
Loading history...
38
        'FormSchema' => '%$' . FormSchema::class,
39
    ];
40
41
    /**
42
     * Current form schema helper
43
     *
44
     * @var FormSchema
45
     */
46
    protected $schema = null;
47
48
    /**
49
     * Get form schema helper
50
     *
51
     * @return FormSchema
52
     */
53 3
    public function getFormSchema()
54
    {
55 3
        return $this->schema;
56
    }
57
58
    /**
59
     * Set form schema helper for this controller
60
     *
61
     * @param FormSchema $schema
62
     * @return $this
63
     */
64 3
    public function setFormSchema(FormSchema $schema)
65
    {
66 3
        $this->schema = $schema;
67 3
        return $this;
68
    }
69
70
    /**
71
     *
72
     */
73 1
    public function onBeforeInit()
74
    {
75
        // stops script from loading
76 1
        Requirements::block('jquery-locator');
77
78
        // require i18n translation stuff
79 1
        Requirements::javascript('silverstripe/admin: client/dist/js/i18n.js');
80 1
        Requirements::add_i18n_javascript('dynamic/silverstripe-locator-react: client/lang');
0 ignored issues
show
Deprecated Code introduced by
The function SilverStripe\View\Requir...::add_i18n_javascript() has been deprecated. ( Ignorable by Annotation )

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

80
        /** @scrutinizer ignore-deprecated */ Requirements::add_i18n_javascript('dynamic/silverstripe-locator-react: client/lang');
Loading history...
81
82
        // because we need another library when using autocomplete
83 1
        if ($this->owner->Autocomplete) {
0 ignored issues
show
Bug Best Practice introduced by
The property Autocomplete does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. Did you maybe forget to declare it?
Loading history...
84
            // google maps api key
85 1
            $key = Config::inst()->get(GoogleGeocoder::class, 'map_api_key');
86 1
            Requirements::block("https://maps.google.com/maps/api/js?key={$key}");
87 1
            Requirements::javascript("https://maps.google.com/maps/api/js?key={$key}&libraries=places");
88
        }
89
90 1
        Requirements::customScript("
91
            window.ss = window.ss || {};
92 1
            window.ss.config = " . $this->owner->getClientConfig() . ";
0 ignored issues
show
Bug introduced by
The method getClientConfig() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

92
            window.ss.config = " . $this->owner->/** @scrutinizer ignore-call */ getClientConfig() . ";

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
93
        ");
94
95 1
        $this->owner->customScript();
0 ignored issues
show
Bug introduced by
The method customScript() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

95
        $this->owner->/** @scrutinizer ignore-call */ 
96
                      customScript();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
96
    }
97
98
    /**
99
     * Generates the custom script for settings
100
     */
101 2
    public function customScript()
102
    {
103 2
        $radii = $this->owner->getShowRadius() ? $this->owner->getRadii() : [];
0 ignored issues
show
Bug introduced by
The method getRadii() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

103
        $radii = $this->owner->getShowRadius() ? $this->owner->/** @scrutinizer ignore-call */ getRadii() : [];

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method getShowRadius() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

103
        $radii = $this->owner->/** @scrutinizer ignore-call */ getShowRadius() ? $this->owner->getRadii() : [];

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method getShowRadius() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

103
        $radii = $this->owner->/** @scrutinizer ignore-call */ getShowRadius() ? $this->owner->getRadii() : [];

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method getRadii() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

103
        $radii = $this->owner->getShowRadius() ? $this->owner->/** @scrutinizer ignore-call */ getRadii() : [];

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
104 2
        $radiiString = json_encode($radii);
105
106 2
        $categories = $this->owner->getUsedCategories();
0 ignored issues
show
Bug introduced by
The method getUsedCategories() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

106
        /** @scrutinizer ignore-call */ 
107
        $categories = $this->owner->getUsedCategories();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method getUsedCategories() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

106
        /** @scrutinizer ignore-call */ 
107
        $categories = $this->owner->getUsedCategories();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
107 2
        $categoriesString = $this->owner->categoriesString($categories);
0 ignored issues
show
Bug introduced by
The method categoriesString() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

107
        /** @scrutinizer ignore-call */ 
108
        $categoriesString = $this->owner->categoriesString($categories);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
108
109 2
        $unit = $this->owner->Unit ? $this->owner->Unit : 'm';
0 ignored issues
show
Bug Best Practice introduced by
The property Unit does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. Did you maybe forget to declare it?
Loading history...
Bug introduced by
The property Unit does not seem to exist on Dynamic\Locator\React\Extensions\LocatorExtension.
Loading history...
110
        // otherwise this is 0 or 1
111 2
        $clusters = $this->owner->Clusters ? 'true' : 'false';
0 ignored issues
show
Bug Best Practice introduced by
The property Clusters does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. Did you maybe forget to declare it?
Loading history...
112 2
        $autocomplete = $this->owner->Autocomplete ? 'true' : 'false';
0 ignored issues
show
Bug Best Practice introduced by
The property Autocomplete does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. Did you maybe forget to declare it?
Loading history...
113
114 2
        $stylePath = ModuleResourceLoader::singleton()->resolveURL($this->owner->getMapStyle());
0 ignored issues
show
Bug introduced by
The method getMapStyle() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

114
        $stylePath = ModuleResourceLoader::singleton()->resolveURL($this->owner->/** @scrutinizer ignore-call */ getMapStyle());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method getMapStyle() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

114
        $stylePath = ModuleResourceLoader::singleton()->resolveURL($this->owner->/** @scrutinizer ignore-call */ getMapStyle());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
115 2
        $searchMarkerIconPath = $this->owner->SearchMarkerImage ? $this->owner->SearchMarkerImage->URL : 'undefined';
0 ignored issues
show
Bug Best Practice introduced by
The property SearchMarkerImage does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. Did you maybe forget to declare it?
Loading history...
Bug introduced by
The property SearchMarkerImage does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. Did you mean SearchMarkerImageID?
Loading history...
116 2
        $markerIconPath = ModuleResourceLoader::singleton()->resolveURL($this->owner->getMarkerIcon());
0 ignored issues
show
Bug introduced by
The method getMarkerIcon() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

116
        $markerIconPath = ModuleResourceLoader::singleton()->resolveURL($this->owner->/** @scrutinizer ignore-call */ getMarkerIcon());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method getMarkerIcon() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

116
        $markerIconPath = ModuleResourceLoader::singleton()->resolveURL($this->owner->/** @scrutinizer ignore-call */ getMarkerIcon());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
117 2
        if ($this->owner->DefaultMarkerImage) {
0 ignored issues
show
Bug introduced by
The property DefaultMarkerImage does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. Did you mean DefaultMarkerImageID?
Loading history...
Bug Best Practice introduced by
The property DefaultMarkerImage does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. Did you maybe forget to declare it?
Loading history...
118 2
            $markerIconPath = $this->owner->DefaultMarkerImage->URL;
119
        }
120
121
        // force to float
122 2
        $defaultLat = (float)$this->owner->DefaultLat;
0 ignored issues
show
Bug Best Practice introduced by
The property DefaultLat does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. Did you maybe forget to declare it?
Loading history...
123 2
        $defaultLng = (float)$this->owner->DefaultLng;
0 ignored issues
show
Bug Best Practice introduced by
The property DefaultLng does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. Did you maybe forget to declare it?
Loading history...
124
125 2
        Requirements::customScript("
126
            window.dynamic_locator = {
127 2
                'radii': {$radiiString},
128 2
                'categories': {$categoriesString},
129 2
                'unit': '{$unit}',
130 2
                'limit': {$this->owner->getLimit()},
0 ignored issues
show
Bug introduced by
The method getLimit() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

130
                'limit': {$this->owner->/** @scrutinizer ignore-call */ getLimit()},

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method getLimit() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

130
                'limit': {$this->owner->/** @scrutinizer ignore-call */ getLimit()},

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
131 2
                'clusters': {$clusters},
132 2
                'mapStylePath': '{$stylePath}',
133 2
                'searchMarkerImagePath': '{$searchMarkerIconPath}',
134 2
                'markerImagePath': '{$markerIconPath}',
135
                'defaultCenter': {
136 2
                    'lat': {$defaultLat},
137 2
                    'lng': {$defaultLng}
138
                },
139 2
                'autocomplete': {$autocomplete}
140
            };
141 2
        ", 'react-locator');
142
    }
143
144
    /**
145
     * @param $categories
146
     *
147
     * @return string
148
     */
149 3
    public function categoriesString($categories)
150
    {
151 3
        $string = '[';
152 3
        for ($i = 0; $i < $categories->count(); $i++) {
153 1
            $cat = $categories[$i];
154 1
            $ID = $cat->ID;
155 1
            $Name = $cat->Name;
156
            $string .= "{
157 1
                'ID': {$ID},
158 1
                'Name': '{$Name}'
159
            }";
160
161 1
            if ($i !== $categories->count() - 1) {
162 1
                $string .= ',';
163
            }
164
        }
165 3
        $string .= ']';
166
167 3
        return $string;
168
    }
169
170
    /**
171
     * @return string
172
     */
173 1
    public function getClientConfig()
174
    {
175 1
        $token = SecurityToken::inst();
176
177
        $clientConfig = [
178 1
            'name' => get_class($this->owner),
179 1
            'url' => trim($this->owner->Link(), '/'),
0 ignored issues
show
Bug introduced by
The method Link() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

179
            'url' => trim($this->owner->/** @scrutinizer ignore-call */ Link(), '/'),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method Link() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

179
            'url' => trim($this->owner->/** @scrutinizer ignore-call */ Link(), '/'),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
180 1
            'baseUrl' => Director::baseURL(),
181 1
            'absoluteBaseUrl' => Director::absoluteBaseURL(),
182 1
            $token->getName() => $token->getValue(),
183
            'sections' => [],
184 1
            'debugging' => $this->owner->config()->get('debugging'),
0 ignored issues
show
Bug introduced by
The method config() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

184
            'debugging' => $this->owner->/** @scrutinizer ignore-call */ config()->get('debugging'),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method config() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

184
            'debugging' => $this->owner->/** @scrutinizer ignore-call */ config()->get('debugging'),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
185
        ];
186
187 1
        $clientConfig['sections'][] = Injector::inst()->get(LeftAndMain::class)->getClientConfig();
188
189 1
        $this->owner->extend('updateClientConfig', $clientConfig);
0 ignored issues
show
Bug introduced by
The method extend() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

189
        $this->owner->/** @scrutinizer ignore-call */ 
190
                      extend('updateClientConfig', $clientConfig);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method extend() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

189
        $this->owner->/** @scrutinizer ignore-call */ 
190
                      extend('updateClientConfig', $clientConfig);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
190
191 1
        return Convert::raw2json($clientConfig);
0 ignored issues
show
Deprecated Code introduced by
The function SilverStripe\Core\Convert::raw2json() has been deprecated: 4.4.0:5.0.0 Use json_encode() instead ( Ignorable by Annotation )

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

191
        return /** @scrutinizer ignore-deprecated */ Convert::raw2json($clientConfig);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
192
    }
193
194
    /**
195
     * Gets a JSON schema representing the search form.
196
     *
197
     * @param HTTPRequest $request
0 ignored issues
show
Bug introduced by
The type Dynamic\Locator\React\Extensions\HTTPRequest was not found. Did you mean HTTPRequest? If so, make sure to prefix the type with \.
Loading history...
198
     * @return HTTPResponse
199
     */
200
    public function schema($request)
0 ignored issues
show
Unused Code introduced by
The parameter $request 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

200
    public function schema(/** @scrutinizer ignore-unused */ $request)

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...
201
    {
202
        return $this->getSchemaResponse("Locator.SearchForm", $this->owner->LocationSearch());
0 ignored issues
show
Bug introduced by
The method LocationSearch() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

202
        return $this->getSchemaResponse("Locator.SearchForm", $this->owner->/** @scrutinizer ignore-call */ LocationSearch());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method LocationSearch() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

202
        return $this->getSchemaResponse("Locator.SearchForm", $this->owner->/** @scrutinizer ignore-call */ LocationSearch());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
203
    }
204
205
    /**
206
     * Check if the current request has a X-Formschema-Request header set.
207
     * Used by conditional logic that responds to validation results
208
     *
209
     * @return bool
210
     */
211
    protected function getSchemaRequested()
212
    {
213
        $parts = $this->owner->getRequest()->getHeader(LeftAndMain::SCHEMA_HEADER);
0 ignored issues
show
Bug introduced by
The method getRequest() does not exist on Dynamic\Locator\React\Ex...atorControllerExtension. ( Ignorable by Annotation )

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

213
        $parts = $this->owner->/** @scrutinizer ignore-call */ getRequest()->getHeader(LeftAndMain::SCHEMA_HEADER);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method getRequest() does not exist on Dynamic\Locator\React\Extensions\LocatorExtension. ( Ignorable by Annotation )

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

213
        $parts = $this->owner->/** @scrutinizer ignore-call */ getRequest()->getHeader(LeftAndMain::SCHEMA_HEADER);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
214
        return !empty($parts);
215
    }
216
217
    /**
218
     * Generate schema for the given form based on the X-Formschema-Request header value
219
     *
220
     * @param string $schemaID ID for this schema. Required.
221
     * @param Form $form Required for 'state' or 'schema' response
0 ignored issues
show
Bug introduced by
The type Dynamic\Locator\React\Extensions\Form 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...
222
     * @param ValidationResult $errors Required for 'error' response
223
     * @param array $extraData Any extra data to be merged with the schema response
224
     * @return HTTPResponse
225
     */
226
    protected function getSchemaResponse($schemaID, $form = null, ValidationResult $errors = null, $extraData = [])
0 ignored issues
show
Bug introduced by
The type Dynamic\Locator\React\Extensions\ValidationResult 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...
227
    {
228
        $parts = $this->owner->getRequest()->getHeader(LeftAndMain::SCHEMA_HEADER);
229
        $data = $this
230
            ->getFormSchema()
231
            ->getMultipartSchema($parts, $schemaID, $form, $errors);
232
233
        if ($extraData) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $extraData of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
234
            $data = array_merge($data, $extraData);
235
        }
236
237
        $response = new HTTPResponse(Convert::raw2json($data));
0 ignored issues
show
Deprecated Code introduced by
The function SilverStripe\Core\Convert::raw2json() has been deprecated: 4.4.0:5.0.0 Use json_encode() instead ( Ignorable by Annotation )

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

237
        $response = new HTTPResponse(/** @scrutinizer ignore-deprecated */ Convert::raw2json($data));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
238
        $response->addHeader('Content-Type', 'application/json');
239
        return $response;
240
    }
241
}
242