Passed
Push — v1 ( a623fc...76f4e4 )
by Andrew
10:06 queued 02:57
created

SectionsController::actionPageDetail()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 64
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 42
dl 0
loc 64
rs 8.9368
c 0
b 0
f 0
cc 5
nc 8
nop 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Webperf plugin for Craft CMS 3.x
4
 *
5
 * Monitor the performance of your webpages through real-world user timing data
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) 2019 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\webperf\controllers;
12
13
use nystudio107\webperf\Webperf;
14
use nystudio107\webperf\assetbundles\webperf\WebperfDashboardAsset;
15
use nystudio107\webperf\helpers\MultiSite as MultiSiteHelper;
16
use nystudio107\webperf\helpers\Permission as PermissionHelper;
17
18
use Craft;
0 ignored issues
show
Bug introduced by
The type Craft 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\helpers\UrlHelper;
0 ignored issues
show
Bug introduced by
The type craft\helpers\UrlHelper 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...
20
use craft\web\Controller;
0 ignored issues
show
Bug introduced by
The type craft\web\Controller 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...
21
22
use yii\base\InvalidConfigException;
0 ignored issues
show
Bug introduced by
The type yii\base\InvalidConfigException 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...
23
use yii\web\NotFoundHttpException;
0 ignored issues
show
Bug introduced by
The type yii\web\NotFoundHttpException 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...
24
use yii\web\Response;
0 ignored issues
show
Bug introduced by
The type yii\web\Response 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...
25
26
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
27
 * @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 indented incorrectly; expected 2 spaces but found 4
Loading history...
28
 * @package   Webperf
0 ignored issues
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 3
Loading history...
29
 * @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 indented incorrectly; expected 3 spaces but found 5
Loading history...
30
 */
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...
31
class SectionsController extends Controller
32
{
33
    // Constants
34
    // =========================================================================
35
36
    const DOCUMENTATION_URL = 'https://github.com/nystudio107/craft-webperf/';
37
38
    const WEBHOOKS_PLUGIN_HANDLE = 'webhooks';
39
40
    // Protected Properties
41
    // =========================================================================
42
43
    protected $allowAnonymous = [];
44
45
    // Public Methods
46
    // =========================================================================
47
48
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
49
     * @param string|null $siteHandle
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
50
     * @param bool        $showWelcome
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
51
     *
52
     * @return Response
53
     * @throws NotFoundHttpException
54
     * @throws \yii\web\ForbiddenHttpException
55
     */
56
    public function actionDashboard(string $siteHandle = null, bool $showWelcome = false): Response
57
    {
58
        $variables = [];
59
        PermissionHelper::controllerPermissionCheck('webperf:dashboard');
60
        // Trim the statistics
61
        Webperf::$plugin->dataSamples->trimOrphanedSamples(1024);
62
        Webperf::$plugin->dataSamples->trimDataSamples();
63
        // Get the site to edit
64
        $siteId = MultiSiteHelper::getSiteIdFromHandle($siteHandle);
65
        $pluginName = Webperf::$settings->pluginName;
66
        $templateTitle = Craft::t('webperf', 'Dashboard');
67
        $view = Craft::$app->getView();
68
        // Asset bundle
69
        try {
70
            $view->registerAssetBundle(WebperfDashboardAsset::class);
71
        } catch (InvalidConfigException $e) {
72
            Craft::error($e->getMessage(), __METHOD__);
73
        }
74
        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
75
            '@nystudio107/webperf/assetbundles/webperf/dist',
76
            true
77
        );
78
        // Enabled sites
79
        MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);
80
        $variables['controllerHandle'] = 'dashboard';
81
        // Basic variables
82
        $variables['fullPageForm'] = false;
83
        $variables['docsUrl'] = self::DOCUMENTATION_URL;
84
        $variables['pluginName'] = $pluginName;
85
        $variables['title'] = $templateTitle;
86
        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
87
        $variables['crumbs'] = [
88
            [
89
                'label' => $pluginName,
90
                'url' => UrlHelper::cpUrl('webperf'),
91
            ],
92
            [
93
                'label' => $templateTitle,
94
                'url' => UrlHelper::cpUrl('webperf/dashboard'.$siteHandleUri),
95
            ],
96
        ];
97
        $variables['docTitle'] = "{$pluginName} - {$templateTitle}";
98
        $variables['selectedSubnavItem'] = 'dashboard';
99
        $variables['showWelcome'] = $showWelcome;
100
        $variables['settings'] = Webperf::$settings;
101
        // Set the default date range
102
        $now = new \DateTime();
103
        $variables['end'] = $now->format('Y-m-d');
104
        $variables['start'] = $now->modify('-1 year')->format('Y-m-d');
105
106
        // Render the template
107
        return $this->renderTemplate('webperf/dashboard/index', $variables);
108
    }
109
110
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
111
     * @param string|null $siteHandle
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
112
     *
113
     * @return Response
114
     * @throws NotFoundHttpException
115
     * @throws \yii\web\ForbiddenHttpException
116
     */
117
    public function actionPagesIndex(string $siteHandle = null): Response
118
    {
119
        $variables = [];
120
        PermissionHelper::controllerPermissionCheck('webperf:performance');
121
        // Trim the statistics
122
        Webperf::$plugin->dataSamples->trimOrphanedSamples(1024);
123
        Webperf::$plugin->dataSamples->trimDataSamples();
124
        // Get the site to edit
125
        $siteId = MultiSiteHelper::getSiteIdFromHandle($siteHandle);
126
        $pluginName = Webperf::$settings->pluginName;
127
        $templateTitle = Craft::t('webperf', 'Performance');
128
        $view = Craft::$app->getView();
129
        // Asset bundle
130
        try {
131
            $view->registerAssetBundle(WebperfDashboardAsset::class);
132
        } catch (InvalidConfigException $e) {
133
            Craft::error($e->getMessage(), __METHOD__);
134
        }
135
        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
136
            '@nystudio107/webperf/assetbundles/webperf/dist',
137
            true
138
        );
139
        // Enabled sites
140
        MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);
141
        $variables['controllerHandle'] = 'performance';
142
143
        // Basic variables
144
        $variables['fullPageForm'] = false;
145
        $variables['docsUrl'] = self::DOCUMENTATION_URL;
146
        $variables['pluginName'] = $pluginName;
147
        $variables['title'] = $templateTitle;
148
        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
149
        $variables['crumbs'] = [
150
            [
151
                'label' => $pluginName,
152
                'url' => UrlHelper::cpUrl('webperf'),
153
            ],
154
            [
155
                'label' => $templateTitle,
156
                'url' => UrlHelper::cpUrl('webperf/performance'.$siteHandleUri),
157
            ],
158
        ];
159
        $variables['docTitle'] = "{$pluginName} - {$templateTitle}";
160
        $variables['selectedSubnavItem'] = 'performance';
161
        $variables['settings'] = Webperf::$settings;
162
        // Set the default date range
163
        $now = new \DateTime();
164
        $variables['end'] = $now->format('Y-m-d');
165
        $variables['start'] = $now->modify('-1 year')->format('Y-m-d');
166
167
        // Render the template
168
        return $this->renderTemplate('webperf/performance/index', $variables);
169
    }
170
171
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
172
     * @param string      $pageUrl
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
173
     * @param string|null $siteHandle
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
174
     *
175
     * @return Response
176
     * @throws NotFoundHttpException
177
     * @throws \yii\web\ForbiddenHttpException
178
     */
179
    public function actionPageDetail(string $pageUrl, string $siteHandle = null): Response
180
    {
181
        $variables = [];
182
        PermissionHelper::controllerPermissionCheck('webperf:performance-detail');
183
        // Trim the statistics
184
        Webperf::$plugin->dataSamples->trimOrphanedSamples(1024);
185
        Webperf::$plugin->dataSamples->trimDataSamples();
186
        // Get the site to edit
187
        $siteId = MultiSiteHelper::getSiteIdFromHandle($siteHandle);
188
        $pluginName = Webperf::$settings->pluginName;
189
        $templateTitle = Craft::t('webperf', 'Performance Detail');
190
        $view = Craft::$app->getView();
191
        // Asset bundle
192
        try {
193
            $view->registerAssetBundle(WebperfDashboardAsset::class);
194
        } catch (InvalidConfigException $e) {
195
            Craft::error($e->getMessage(), __METHOD__);
196
        }
197
        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
198
            '@nystudio107/webperf/assetbundles/webperf/dist',
199
            true
200
        );
201
        // Enabled sites
202
        MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);
203
        $variables['controllerHandle'] = 'performance/page-detail';
204
205
        // Basic variables
206
        $variables['fullPageForm'] = false;
207
        $variables['docsUrl'] = self::DOCUMENTATION_URL;
208
        $variables['pluginName'] = $pluginName;
209
        $variables['title'] = $templateTitle;
210
        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
211
        $variables['crumbs'] = [
212
            [
213
                'label' => $pluginName,
214
                'url' => UrlHelper::cpUrl('webperf'),
215
            ],
216
            [
217
                'label' => Craft::t('webperf', 'Performance'),
218
                'url' => UrlHelper::cpUrl('webperf/performance'.$siteHandleUri),
219
            ],
220
            [
221
                'label' => $templateTitle,
222
                'url' => UrlHelper::cpUrl('webperf/performance/page-detail'.$siteHandleUri, [
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...
223
                    'pageUrl' => $pageUrl
224
                ]),
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...
225
            ],
226
        ];
227
        $variables['docTitle'] = "{$pluginName} - {$templateTitle}";
228
        $variables['selectedSubnavItem'] = 'performance';
229
        $variables['pageUrl'] = $pageUrl;
230
        $variables['pageTitle'] = Webperf::$plugin->dataSamples->pageTitle($pageUrl, $siteId);
231
        $variables['settings'] = Webperf::$settings;
232
        $variables['webpageTestApiKey'] = Webperf::$settings->webpageTestApiKey;
233
        if (Webperf::$craft31 && $variables['webpageTestApiKey']) {
234
            $variables['webpageTestApiKey'] = Craft::parseEnv($variables['webpageTestApiKey']);
235
        }
236
        // Set the default date range
237
        $now = new \DateTime();
238
        $variables['end'] = $now->format('Y-m-d');
239
        $variables['start'] = $now->modify('-1 year')->format('Y-m-d');
240
241
        // Render the template
242
        return $this->renderTemplate('webperf/performance/page-detail', $variables);
243
    }
244
245
246
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
247
     * @param string|null $siteHandle
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
248
     *
249
     * @return Response
250
     * @throws NotFoundHttpException
251
     * @throws \yii\web\ForbiddenHttpException
252
     */
253
    public function actionErrorsIndex(string $siteHandle = null): Response
254
    {
255
        $variables = [];
256
        PermissionHelper::controllerPermissionCheck('webperf:errors');
257
        // Trim the statistics
258
        Webperf::$plugin->errorSamples->trimErrorSamples();
259
        // Get the site to edit
260
        $siteId = MultiSiteHelper::getSiteIdFromHandle($siteHandle);
261
        $pluginName = Webperf::$settings->pluginName;
262
        $templateTitle = Craft::t('webperf', 'Errors');
263
        $view = Craft::$app->getView();
264
        // Asset bundle
265
        try {
266
            $view->registerAssetBundle(WebperfDashboardAsset::class);
267
        } catch (InvalidConfigException $e) {
268
            Craft::error($e->getMessage(), __METHOD__);
269
        }
270
        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
271
            '@nystudio107/webperf/assetbundles/webperf/dist',
272
            true
273
        );
274
        // Enabled sites
275
        MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);
276
        $variables['controllerHandle'] = 'errors';
277
278
        // Basic variables
279
        $variables['fullPageForm'] = false;
280
        $variables['docsUrl'] = self::DOCUMENTATION_URL;
281
        $variables['pluginName'] = $pluginName;
282
        $variables['title'] = $templateTitle;
283
        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
284
        $variables['crumbs'] = [
285
            [
286
                'label' => $pluginName,
287
                'url' => UrlHelper::cpUrl('webperf'),
288
            ],
289
            [
290
                'label' => $templateTitle,
291
                'url' => UrlHelper::cpUrl('webperf/errors'.$siteHandleUri),
292
            ],
293
        ];
294
        $variables['docTitle'] = "{$pluginName} - {$templateTitle}";
295
        $variables['selectedSubnavItem'] = 'errors';
296
        $variables['settings'] = Webperf::$settings;
297
        // Set the default date range
298
        $now = new \DateTime();
299
        $variables['end'] = $now->format('Y-m-d');
300
        $variables['start'] = $now->modify('-1 year')->format('Y-m-d');
301
302
        // Render the template
303
        return $this->renderTemplate('webperf/errors/index', $variables);
304
    }
305
306
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
307
     * @param string      $pageUrl
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
308
     * @param string|null $siteHandle
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
309
     *
310
     * @return Response
311
     * @throws NotFoundHttpException
312
     * @throws \yii\web\ForbiddenHttpException
313
     */
314
    public function actionErrorsDetail(string $pageUrl, string $siteHandle = null): Response
315
    {
316
        $variables = [];
317
        PermissionHelper::controllerPermissionCheck('webperf:errors-detail');
318
        // Trim the statistics
319
        Webperf::$plugin->errorSamples->trimErrorSamples();
320
        // Get the site to edit
321
        $siteId = MultiSiteHelper::getSiteIdFromHandle($siteHandle);
322
        $pluginName = Webperf::$settings->pluginName;
323
        $templateTitle = Craft::t('webperf', 'Errors Detail');
324
        $view = Craft::$app->getView();
325
        // Asset bundle
326
        try {
327
            $view->registerAssetBundle(WebperfDashboardAsset::class);
328
        } catch (InvalidConfigException $e) {
329
            Craft::error($e->getMessage(), __METHOD__);
330
        }
331
        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
332
            '@nystudio107/webperf/assetbundles/webperf/dist',
333
            true
334
        );
335
        // Enabled sites
336
        MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);
337
        $variables['controllerHandle'] = 'errors/page-detail';
338
339
        // Basic variables
340
        $variables['fullPageForm'] = false;
341
        $variables['docsUrl'] = self::DOCUMENTATION_URL;
342
        $variables['pluginName'] = $pluginName;
343
        $variables['title'] = $templateTitle;
344
        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
345
        $variables['crumbs'] = [
346
            [
347
                'label' => $pluginName,
348
                'url' => UrlHelper::cpUrl('webperf'),
349
            ],
350
            [
351
                'label' => Craft::t('webperf', 'Errors'),
352
                'url' => UrlHelper::cpUrl('webperf/errors'.$siteHandleUri),
353
            ],
354
            [
355
                'label' => $templateTitle,
356
                'url' => UrlHelper::cpUrl('webperf/errors/page-detail'.$siteHandleUri, [
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...
357
                    'pageUrl' => $pageUrl
358
                ]),
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...
359
            ],
360
        ];
361
        $variables['docTitle'] = "{$pluginName} - {$templateTitle}";
362
        $variables['selectedSubnavItem'] = 'errors';
363
        $variables['pageUrl'] = $pageUrl;
364
        $variables['pageTitle'] = Webperf::$plugin->errorSamples->pageTitle($pageUrl, $siteId);
365
        $variables['settings'] = Webperf::$settings;
366
        // Set the default date range
367
        $now = new \DateTime();
368
        $variables['end'] = $now->format('Y-m-d');
369
        $variables['start'] = $now->modify('-1 year')->format('Y-m-d');
370
371
        // Render the template
372
        return $this->renderTemplate('webperf/errors/page-detail', $variables);
373
    }
374
375
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
376
     * @param string|null $siteHandle
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
377
     *
378
     * @return Response
379
     * @throws NotFoundHttpException
380
     * @throws \yii\web\ForbiddenHttpException
381
     */
382
    public function actionAlerts(string $siteHandle = null): Response
383
    {
384
        $variables = [];
385
        PermissionHelper::controllerPermissionCheck('webperf:alerts');
386
        // Get the site to edit
387
        $siteId = MultiSiteHelper::getSiteIdFromHandle($siteHandle);
388
        $pluginName = Webperf::$settings->pluginName;
389
        $templateTitle = Craft::t('webperf', 'Alerts');
390
        $view = Craft::$app->getView();
391
        // Asset bundle
392
        try {
393
            $view->registerAssetBundle(WebperfDashboardAsset::class);
394
        } catch (InvalidConfigException $e) {
395
            Craft::error($e->getMessage(), __METHOD__);
396
        }
397
        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
398
            '@nystudio107/webperf/assetbundles/webperf/dist',
399
            true
400
        );
401
        // Enabled sites
402
        MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);
403
        $variables['controllerHandle'] = 'alerts';
404
        // Basic variables
405
        $variables['fullPageForm'] = true;
406
        $variables['docsUrl'] = self::DOCUMENTATION_URL;
407
        $variables['pluginName'] = $pluginName;
408
        $variables['title'] = $templateTitle;
409
        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
410
        $variables['crumbs'] = [
411
            [
412
                'label' => $pluginName,
413
                'url' => UrlHelper::cpUrl('webperf'),
414
            ],
415
            [
416
                'label' => $templateTitle,
417
                'url' => UrlHelper::cpUrl('webperf/alerts'.$siteHandleUri),
418
            ],
419
        ];
420
        $variables['docTitle'] = "{$pluginName} - {$templateTitle}";
421
        $variables['selectedSubnavItem'] = 'alerts';
422
        $variables['settings'] = Webperf::$settings;
423
        $variables['webhooks'] = Craft::$app->getPlugins()->getPlugin(self::WEBHOOKS_PLUGIN_HANDLE);
424
425
        // Render the template
426
        return $this->renderTemplate('webperf/alerts/index', $variables);
427
    }
428
}
429