Passed
Push — develop-v4 ( 22a0f8...f9458b )
by Andrew
24:27 queued 08:22
created

InstantAnalytics::getPullFieldsFromLayoutId()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 13
rs 10
1
<?php
2
/**
3
 * Instant Analytics plugin for Craft CMS
4
 *
5
 * Instant Analytics brings full Google Analytics support to your Twig templates
6
 *
7
 * @link      https://nystudio107.com
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @copyright tag
Loading history...
8
 * @copyright Copyright (c) 2017 nystudio107
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
9
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
10
11
namespace nystudio107\instantanalyticsGa4;
12
13
use Craft;
14
use craft\base\Model;
15
use craft\base\Plugin;
16
use craft\commerce\elements\Order;
0 ignored issues
show
Bug introduced by
The type craft\commerce\elements\Order 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...
17
use craft\commerce\events\LineItemEvent;
0 ignored issues
show
Bug introduced by
The type craft\commerce\events\LineItemEvent 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...
18
use craft\commerce\Plugin as Commerce;
0 ignored issues
show
Bug introduced by
The type craft\commerce\Plugin 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...
19
use craft\events\PluginEvent;
20
use craft\events\RegisterUrlRulesEvent;
21
use craft\events\TemplateEvent;
22
use craft\helpers\UrlHelper;
23
use craft\services\Plugins;
24
use craft\web\twig\variables\CraftVariable;
25
use craft\web\UrlManager;
26
use craft\web\View;
27
use Exception;
28
use nystudio107\instantanalyticsGa4\helpers\Analytics;
29
use nystudio107\instantanalyticsGa4\helpers\Field as FieldHelper;
30
use nystudio107\instantanalyticsGa4\models\Settings;
31
use nystudio107\instantanalyticsGa4\services\ServicesTrait;
32
use nystudio107\instantanalyticsGa4\twigextensions\InstantAnalyticsTwigExtension;
33
use nystudio107\instantanalyticsGa4\variables\InstantAnalyticsVariable;
34
use nystudio107\seomatic\Seomatic;
0 ignored issues
show
Bug introduced by
The type nystudio107\seomatic\Seomatic 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...
35
use yii\base\Event;
36
use yii\web\Response;
37
use function array_merge;
38
39
/** @noinspection MissingPropertyAnnotationsInspection */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
40
41
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
42
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
43
 * @package   InstantAnalytics
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
44
 * @since     1.0.0
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
Coding Style introduced by
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
45
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
46
class InstantAnalytics extends Plugin
47
{
48
    // Traits
49
    // =========================================================================
50
51
    use ServicesTrait;
52
53
    // Constants
54
    // =========================================================================
55
56
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
57
     * @var string
58
     */
59
    protected const COMMERCE_PLUGIN_HANDLE = 'commerce';
60
61
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
62
     * @var string
63
     */
64
    protected const SEOMATIC_PLUGIN_HANDLE = 'seomatic';
65
66
    // Static Properties
67
    // =========================================================================
68
69
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
70
     * @var null|InstantAnalytics
71
     */
72
    public static ?InstantAnalytics $plugin = null;
73
74
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
75
     * @var null|Settings
76
     */
77
    public static ?Settings $settings = null;
78
79
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
80
     * @var null|Commerce
81
     */
82
    public static ?Commerce $commercePlugin = null;
83
84
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
85
     * @var null|Seomatic
86
     */
87
    public static ?Seomatic $seomaticPlugin = null;
88
89
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
90
     * @var string
91
     */
92
    public static string $currentTemplate = '';
93
94
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
95
     * @var bool
96
     */
97
    public static bool $pageViewSent = false;
98
99
    // Public Properties
100
    // =========================================================================
101
102
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
103
     * @var string
104
     */
105
    public string $schemaVersion = '1.0.0';
106
107
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
108
     * @var bool
109
     */
110
    public bool $hasCpSection = false;
111
112
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
113
     * @var bool
114
     */
115
    public bool $hasCpSettings = true;
116
117
    // Public Methods
118
    // =========================================================================
119
120
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
121
     * @inheritdoc
122
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
123
    public function init(): void
124
    {
125
        parent::init();
126
        self::$plugin = $this;
127
        self::$settings = $this->getSettings();
128
129
        // Add in our Craft components
130
        $this->addComponents();
131
        // Install our global event handlers
132
        $this->installEventListeners();
133
134
        Craft::info(
135
            Craft::t(
136
                'instant-analytics-ga4',
137
                '{name} plugin loaded',
138
                ['name' => $this->name]
139
            ),
140
            __METHOD__
141
        );
142
    }
143
144
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
145
     * @inheritdoc
146
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
147
    protected function settingsHtml(): ?string
148
    {
149
        $commerceFields = [];
150
151
        if (self::$commercePlugin !== null) {
152
            $productTypes = self::$commercePlugin->getProductTypes()->getAllProductTypes();
153
154
            foreach ($productTypes as $productType) {
155
                $productFields = $this->getPullFieldsFromLayoutId($productType->fieldLayoutId);
156
                /** @noinspection SlowArrayOperationsInLoopInspection */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
157
                $commerceFields = array_merge($commerceFields, $productFields);
158
                if ($productType->hasVariants) {
159
                    $variantFields = $this->getPullFieldsFromLayoutId($productType->variantFieldLayoutId);
160
                    /** @noinspection SlowArrayOperationsInLoopInspection */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
161
                    $commerceFields = array_merge($commerceFields, $variantFields);
162
                }
163
            }
164
        }
165
166
        // Rend the settings template
167
        try {
168
            return Craft::$app->getView()->renderTemplate(
169
                'instant-analytics-ga4/settings',
170
                [
171
                    'settings' => $this->getSettings(),
172
                    'commerceFields' => $commerceFields,
173
                ]
174
            );
175
        } catch (Exception $exception) {
176
            Craft::error($exception->getMessage(), __METHOD__);
177
        }
178
179
        return '';
180
    }
181
182
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $context should have a doc-comment as per coding-style.
Loading history...
183
     * Handle the `{% hook iaSendPageView %}`
184
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
185
    public function iaSendPageView(/** @noinspection PhpUnusedParameterInspection */ array &$context = []): string
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
186
    {
187
        $this->ga4->addPageViewEvent();
188
        return '';
189
    }
190
191
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $context should have a doc-comment as per coding-style.
Loading history...
192
     * Handle the `{% hook iaInsertGtag %}`
193
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
194
    public function iaInsertGtag(/** @noinspection PhpUnusedParameterInspection */ array &$context = []): string
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
195
    {
196
        $userSegment = '';
197
198
        if (self::$settings->sendUserId) {
199
            $userId = Analytics::getUserId();
200
            if (!empty($userId)) {
201
                $userSegment = "'user_id': '$userId'";
202
            }
203
        }
204
205
        $measurementId = Craft::parseEnv(self::$settings->googleAnalyticsMeasurementId);
0 ignored issues
show
Deprecated Code introduced by
The function Craft::parseEnv() has been deprecated: in 3.7.29. [[App::parseEnv()]] should be used instead. ( Ignorable by Annotation )

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

205
        $measurementId = /** @scrutinizer ignore-deprecated */ Craft::parseEnv(self::$settings->googleAnalyticsMeasurementId);

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...
206
207
        return <<<GTAG
208
<!-- Google tag (gtag.js) -->
209
<script async src="https://www.googletagmanager.com/gtag/js?id=$measurementId"></script>
210
<script>
211
  window.dataLayer = window.dataLayer || [];
212
  function gtag(){dataLayer.push(arguments);}
213
  gtag('js', new Date());
214
215
  gtag('config', '$measurementId', 
216
  {
217
  $userSegment
218
  });
219
</script>
220
GTAG;
221
    }
222
223
    public function logAnalyticsEvent(string $message, array $variables = [], string $category = ''): void
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function logAnalyticsEvent()
Loading history...
224
    {
225
        Craft::info(
226
            Craft::t('instant-analytics-ga4', $message, $variables),
227
            $category
228
        );
229
    }
230
    // Protected Methods
231
    // =========================================================================
232
233
    /**
234
     * Add in our Craft components
235
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
236
    protected function addComponents(): void
237
    {
238
        $view = Craft::$app->getView();
239
        // Add in our Twig extensions
240
        $view->registerTwigExtension(new InstantAnalyticsTwigExtension());
241
        // Install our template hooks
242
        $view->hook('iaSendPageView', [$this, 'iaSendPageView']);
243
        $view->hook('iaInsertGtag', [$this, 'iaInsertGtag']);
244
245
        // Register our variables
246
        Event::on(
247
            CraftVariable::class,
248
            CraftVariable::EVENT_INIT,
249
            function (Event $event): void {
250
                /** @var CraftVariable $variable */
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
251
                $variable = $event->sender;
252
                $variable->set('instantAnalytics', [
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
253
                    'class' => InstantAnalyticsVariable::class,
254
                    'viteService' => $this->vite,
255
                ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
256
            }
257
        );
258
    }
259
260
    /**
261
     * Install our event listeners
262
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
263
    protected function installEventListeners(): void
264
    {
265
        // Handler: Plugins::EVENT_AFTER_INSTALL_PLUGIN
266
        Event::on(
267
            Plugins::class,
268
            Plugins::EVENT_AFTER_INSTALL_PLUGIN,
269
            function (PluginEvent $event): void {
270
                if ($event->plugin === $this) {
0 ignored issues
show
introduced by
The condition $event->plugin === $this is always false.
Loading history...
271
                    $request = Craft::$app->getRequest();
272
                    if ($request->isCpRequest) {
273
                        Craft::$app->getResponse()->redirect(UrlHelper::cpUrl('instant-analytics-ga4/welcome'))->send();
274
                    }
275
                }
276
            }
277
        );
278
279
        // Handler: Plugins::EVENT_AFTER_LOAD_PLUGINS
280
        Event::on(
281
            Plugins::class,
282
            Plugins::EVENT_AFTER_LOAD_PLUGINS,
283
            function () {
284
                // Determine if Craft Commerce is installed & enabled
285
                self::$commercePlugin = Craft::$app->getPlugins()->getPlugin(self::COMMERCE_PLUGIN_HANDLE);
286
                // Determine if SEOmatic is installed & enabled
287
                self::$seomaticPlugin = Craft::$app->getPlugins()->getPlugin(self::SEOMATIC_PLUGIN_HANDLE);
288
289
                // Make sure to install these only after we definitely know whether other plugins are installed
290
                $request = Craft::$app->getRequest();
291
                // Install only for non-console site requests
292
                if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest()) {
293
                    $this->installSiteEventListeners();
294
                }
295
296
                // Install only for non-console Control Panel requests
297
                if ($request->getIsCpRequest() && !$request->getIsConsoleRequest()) {
298
                    $this->installCpEventListeners();
299
                }
300
            }
301
        );
302
    }
303
304
    /**
305
     * Install site event listeners for site requests only
306
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
307
    protected function installSiteEventListeners(): void
308
    {
309
        // Handler: UrlManager::EVENT_REGISTER_SITE_URL_RULES
310
        Event::on(
311
            UrlManager::class,
312
            UrlManager::EVENT_REGISTER_SITE_URL_RULES,
313
            function (RegisterUrlRulesEvent $event): void {
314
                Craft::debug(
315
                    'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
316
                    __METHOD__
317
                );
318
                // Register our Control Panel routes
319
                $event->rules = array_merge(
320
                    $event->rules,
321
                    $this->customFrontendRoutes()
322
                );
323
            }
324
        );
325
        // Remember the name of the currently rendering template
326
        Event::on(
327
            View::class,
328
            View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE,
329
            static function (TemplateEvent $event): void {
330
                self::$currentTemplate = $event->template;
331
            }
332
        );
333
        // Send the page-view event.
334
        Event::on(
335
            View::class,
336
            View::EVENT_AFTER_RENDER_PAGE_TEMPLATE,
337
            function (TemplateEvent $event): void {
0 ignored issues
show
Unused Code introduced by
The parameter $event 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

337
            function (/** @scrutinizer ignore-unused */ TemplateEvent $event): 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...
338
                if (self::$settings->autoSendPageView) {
339
                    $request = Craft::$app->getRequest();
340
                    if (!$request->getIsAjax()) {
341
                        $this->ga4->addPageViewEvent();
342
                    }
343
                }
344
            }
345
        );
346
347
        // Send the collected events
348
        Event::on(
349
            Response::class,
350
            Response::EVENT_BEFORE_SEND,
351
            function (Event $event): void {
0 ignored issues
show
Unused Code introduced by
The parameter $event 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

351
            function (/** @scrutinizer ignore-unused */ Event $event): 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...
352
                // Initialize this sooner rather than later, since it's possible this will want to tinker with cookies
353
                $this->ga4->getAnalytics();
354
            }
355
        );
356
357
        // Send the collected events
358
        Event::on(
359
            Response::class,
360
            Response::EVENT_AFTER_SEND,
361
            function (Event $event): void {
0 ignored issues
show
Unused Code introduced by
The parameter $event 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

361
            function (/** @scrutinizer ignore-unused */ Event $event): 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...
362
                $this->ga4->getAnalytics()->sendCollectedEvents();
363
            }
364
        );
365
366
        // Commerce-specific hooks
367
        if (self::$commercePlugin !== null) {
368
            Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, function (Event $e): void {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
369
                $order = $e->sender;
370
                if (self::$settings->autoSendPurchaseComplete) {
371
                    $this->commerce->triggerOrderCompleteEvent($order);
372
                }
373
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
374
375
            Event::on(Order::class, Order::EVENT_AFTER_ADD_LINE_ITEM, function (LineItemEvent $e): void {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
376
                $lineItem = $e->lineItem;
377
                if (self::$settings->autoSendAddToCart) {
378
                    $this->commerce->triggerAddToCartEvent($lineItem);
379
                }
380
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
381
382
            // Check to make sure Order::EVENT_AFTER_REMOVE_LINE_ITEM is defined
383
            if (defined(Order::class . '::EVENT_AFTER_REMOVE_LINE_ITEM')) {
384
                Event::on(Order::class, Order::EVENT_AFTER_REMOVE_LINE_ITEM, function (LineItemEvent $e): void {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
385
                    $lineItem = $e->lineItem;
386
                    if (self::$settings->autoSendRemoveFromCart) {
387
                        $this->commerce->triggerRemoveFromCartEvent($lineItem);
388
                    }
389
                });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
390
            }
391
        }
392
    }
393
394
    /**
395
     * Install site event listeners for Control Panel requests only
396
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
397
    protected function installCpEventListeners(): void
398
    {
399
    }
400
401
    /**
402
     * Return the custom frontend routes
403
     *
404
     * @return array<string, string>
405
     */
406
    protected function customFrontendRoutes(): array
407
    {
408
        return [
409
            'instantanalytics/pageViewTrack' =>
410
                'instant-analytics-ga4/track/track-page-view-url',
411
            'instantanalytics/eventTrack/<filename:[-\w\.*]+>?' =>
412
                'instant-analytics-ga4/track/track-event-url',
413
        ];
414
    }
415
416
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
417
     * @inheritdoc
418
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
419
    protected function createSettingsModel(): ?Model
420
    {
421
        return new Settings();
422
    }
423
424
    // Private Methods
425
    // =========================================================================
426
427
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
428
     * @param $layoutId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
429
     *
430
     * @return mixed[]|array<string, string>
431
     */
432
    private function getPullFieldsFromLayoutId($layoutId): array
0 ignored issues
show
Coding Style introduced by
Private method name "InstantAnalytics::getPullFieldsFromLayoutId" must be prefixed with an underscore
Loading history...
433
    {
434
        $result = ['' => 'none'];
435
        if ($layoutId === null) {
436
            return $result;
437
        }
438
439
        $fieldLayout = Craft::$app->getFields()->getLayoutById($layoutId);
440
        if ($fieldLayout) {
441
            $result = FieldHelper::fieldsOfTypeFromLayout(FieldHelper::TEXT_FIELD_CLASS_KEY, $fieldLayout, false);
442
        }
443
444
        return $result;
445
    }
446
}
447