GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — action_getCatTree_order ( 77944b )
by
unknown
23:56
created

ProductController   F

Complexity

Total Complexity 54

Size/Duplication

Total Lines 430
Duplicated Lines 12.09 %

Coupling/Cohesion

Components 1
Dependencies 26

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 54
lcom 1
cbo 26
dl 52
loc 430
rs 1.6712
c 1
b 1
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
F actionList() 9 173 28
C actionShow() 9 80 8
B actionSearch() 23 79 4
C buildBreadcrumbsArray() 11 62 14

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like ProductController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ProductController, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace app\modules\shop\controllers;
4
5
use app\components\Controller;
6
use app\extensions\DefaultTheme\components\BaseWidget;
7
use app\extensions\DefaultTheme\models\ThemeActiveWidgets;
8
use app\extensions\DefaultTheme\models\ThemeWidgets;
9
use app\extensions\DefaultTheme\widgets\FilterSets\Widget;
10
use app\models\PropertyStaticValues;
11
use app\modules\core\helpers\EventTriggeringHelper;
12
use app\modules\shop\events\ProductPageShowed;
13
use app\modules\shop\models\Category;
14
use app\models\Object;
15
use app\modules\shop\models\Product;
16
use app\models\Search;
17
use app\traits\DynamicContentTrait;
18
use devgroup\TagDependencyHelper\ActiveRecordHelper;
19
use Yii;
20
use yii\caching\TagDependency;
21
use yii\data\Pagination;
22
use yii\helpers\ArrayHelper;
23
use yii\helpers\Json;
24
use yii\helpers\Url;
25
use yii\web\ForbiddenHttpException;
26
use yii\web\NotFoundHttpException;
27
use yii\web\Response;
28
use yii\web\ServerErrorHttpException;
29
30
class ProductController extends Controller
31
{
32
    use DynamicContentTrait;
33
34
    /**
35
     * Products listing by category with filtration support.
36
     *
37
     * @return string
38
     * @throws \Exception
39
     * @throws NotFoundHttpException
40
     * @throws ServerErrorHttpException
41
     */
42
    public function actionList()
0 ignored issues
show
Coding Style introduced by
actionList uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
Coding Style introduced by
actionList uses the super-global variable $_POST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
43
    {
44
45
        $request = Yii::$app->request;
46
47
        if (null === $request->get('category_group_id')) {
48
            throw new NotFoundHttpException;
49
        }
50
51
        if (null === $object = Object::getForClass(Product::className())) {
52
            throw new ServerErrorHttpException('Object not found.');
53
        }
54
55
        $category_group_id = intval($request->get('category_group_id', 0));
56
57
        $title_append = $request->get('title_append', '');
58
        if (!empty($title_append)) {
59
            $title_append = is_array($title_append) ? implode(' ', $title_append) : $title_append;
60
            unset($_GET['title_append']);
61
        }
62
63
        $values_by_property_id = $request->get('properties', []);
64
        if (!is_array($values_by_property_id)) {
65
            $values_by_property_id = [$values_by_property_id];
66
        }
67
68
        if (Yii::$app->request->isPost && isset($_POST['properties'])) {
69
            if (is_array($_POST['properties'])) {
70
                foreach ($_POST['properties'] as $key => $value) {
71
                    if (isset($values_by_property_id[$key])) {
72
                        $values_by_property_id[$key] = array_unique(
73
                            ArrayHelper::merge(
74
                                $values_by_property_id[$key],
75
                                $value
76
                            )
77
                        );
78
                    } else {
79
                        $values_by_property_id[$key] = array_unique($value);
80
                    }
81
                }
82
            }
83
        }
84
85
        $selected_category_ids = $request->get('categories', []);
86
        if (!is_array($selected_category_ids)) {
87
            $selected_category_ids = [$selected_category_ids];
88
        }
89
90
        if (null !== $selected_category_id = $request->get('last_category_id')) {
91
            $selected_category_id = intval($selected_category_id);
92
        }
93
94
        $result = Product::filteredProducts(
95
            $category_group_id,
96
            $values_by_property_id,
97
            $selected_category_id,
98
            false,
99
            null,
100
            true,
101
            false
102
        );
103
        /** @var Pagination $pages */
104
        $pages = $result['pages'];
105
        if (Yii::$app->response->is_prefiltered_page) {
106
            $pages->route = '/' . Yii::$app->request->pathInfo;
107
            $pages->params = [
108
109
            ];
110
        }
111
        $allSorts = $result['allSorts'];
112
        $products = $result['products'];
113
114
        // throw 404 if we are at filtered page without any products
115
        if ( !empty($values_by_property_id) && empty($products)) {
116
            throw new NotFoundHttpException();
117
        }
118
119
        if (null !== $selected_category = $selected_category_id) {
120
            if ($selected_category_id > 0) {
121
                if (null !== $selected_category = Category::findById($selected_category_id, null)) {
122 View Code Duplication
                    if (!empty($selected_category->meta_description)) {
123
                        $this->view->registerMetaTag(
0 ignored issues
show
Bug introduced by
The method registerMetaTag does only exist in yii\web\View, but not in yii\base\View.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
124
                            [
125
                                'name' => 'description',
126
                                'content' => $selected_category->meta_description,
127
                            ],
128
                            'meta_description'
129
                        );
130
                    }
131
                    $this->view->title = $selected_category->title;
132
                }
133
            }
134
        }
135
        if (is_null($selected_category) || !$selected_category->active) {
136
            throw new NotFoundHttpException;
137
        }
138
139
        if (!empty($title_append)) {
140
            $this->view->title .= " " . $title_append;
141
        }
142
143
        $this->view->blocks['h1'] = $selected_category->h1;
144
        $this->view->blocks['announce'] = $selected_category->announce;
145
        $this->view->blocks['content'] = $selected_category->content;
146
147
        $this->loadDynamicContent($object->id, 'shop/product/list', $request->get());
148
149
        $params = [
150
            'model' => $selected_category,
151
            'selected_category' => $selected_category,
152
            'selected_category_id' => $selected_category_id,
153
            'selected_category_ids' => $selected_category_ids,
154
            'values_by_property_id' => $values_by_property_id,
155
            'products' => $products,
156
            'object' => $object,
157
            'category_group_id' => $category_group_id,
158
            'pages' => $pages,
159
            'title_append' => $title_append,
160
            'selections' => $request->get(),
161
            'breadcrumbs' => $this->buildBreadcrumbsArray($selected_category, null, $values_by_property_id),
162
            'allSorts' => $allSorts,
163
        ];
164
        $viewFile = $this->computeViewFile($selected_category, 'list');
165
166
        if (Yii::$app->request->isAjax) {
167
            Yii::$app->response->format = Response::FORMAT_JSON;
168
169
            $content = $this->renderAjax(
170
                $viewFile,
171
                $params
172
            );
173
            $filters = '';
174
            $activeWidgets = ThemeActiveWidgets::getActiveWidgets();
175
            foreach ($activeWidgets as $activeWidget) {
176
                if ($activeWidget->widget->widget == Widget::className()) {
177
                    /** @var ThemeWidgets $widgetModel */
178
                    $widgetModel = $activeWidget->widget;
179
                    /** @var BaseWidget $widgetClassName */
180
                    $widgetClassName =  $widgetModel->widget;
181
                    $widgetConfiguration = Json::decode($widgetModel->configuration_json, true);
182
                    if (!is_array($widgetConfiguration)) {
183
                        $widgetConfiguration = [];
184
                    }
185
                    $activeWidgetConfiguration = Json::decode($activeWidget->configuration_json, true);
186
                    if (!is_array($activeWidgetConfiguration)) {
187
                        $activeWidgetConfiguration  = [];
188
                    }
189
                    $config = ArrayHelper::merge($widgetConfiguration, $activeWidgetConfiguration);
190
                    $config['themeWidgetModel'] = $widgetModel;
191
                    $config['partRow'] = $activeWidget->part;
192
                    $config['activeWidget'] = $activeWidget;
193
                    $filters = $widgetClassName::widget($config);
194
                }
195
            }
196
            return [
0 ignored issues
show
Bug Best Practice introduced by
The return type of return array('content' =...lues_by_property_id))); (array) is incompatible with the return type documented by app\modules\shop\control...tController::actionList of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
197
                'content' => $content,
198
                'filters' => $filters,
199
                'title' => $this->view->title,
200
                'url' => Url::to(
201
                    [
202
                        '/shop/product/list',
203
                        'last_category_id' => $selected_category_id,
204
                        'properties' => $values_by_property_id
205
                    ]
206
                ),
207
            ];
208
        } else {
209
            return $this->render(
210
                $viewFile,
211
                $params
212
            );
213
        }
214
    }
215
216
    /**
217
     * Product page view
218
     *
219
     * @param null $model_id
220
     * @return string
221
     * @throws NotFoundHttpException
222
     * @throws ServerErrorHttpException
223
     */
224
    public function actionShow($model_id = null)
225
    {
226
        if (null === $object = Object::getForClass(Product::className())) {
227
            throw new ServerErrorHttpException('Object not found.');
228
        }
229
230
        $cacheKey = 'Product:' . $model_id;
231
        if (false === $product = Yii::$app->cache->get($cacheKey)) {
232
            if (null === $product = Product::findById($model_id)) {
233
                throw new NotFoundHttpException;
234
            }
235
            Yii::$app->cache->set(
236
                $cacheKey,
237
                $product,
238
                86400,
239
                new TagDependency(
240
                    [
241
                        'tags' => [
242
                            ActiveRecordHelper::getObjectTag(Product::className(), $model_id),
243
                        ]
244
                    ]
245
                )
246
            );
247
        }
248
249
        $request = Yii::$app->request;
250
251
        $values_by_property_id = $request->get('properties', []);
252
        if (!is_array($values_by_property_id)) {
253
            $values_by_property_id = [$values_by_property_id];
254
        }
255
256
        $selected_category_id = $request->get('last_category_id');
257
258
        $selected_category_ids = $request->get('categories', []);
259
        if (!is_array($selected_category_ids)) {
260
            $selected_category_ids = [$selected_category_ids];
261
        }
262
263
        $category_group_id = intval($request->get('category_group_id', 0));
264
265
        // trigger that we are to show product to user!
266
        // wow! such product! very events!
267
        $specialEvent = new ProductPageShowed([
268
            'product_id' => $product->id,
269
        ]);
270
        EventTriggeringHelper::triggerSpecialEvent($specialEvent);
271
272 View Code Duplication
        if (!empty($product->meta_description)) {
273
            $this->view->registerMetaTag(
0 ignored issues
show
Bug introduced by
The method registerMetaTag does only exist in yii\web\View, but not in yii\base\View.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
274
                [
275
                    'name' => 'description',
276
                    'content' => $product->meta_description,
277
                ],
278
                'meta_description'
279
            );
280
        }
281
282
        $selected_category = ($selected_category_id > 0) ? Category::findById($selected_category_id) : null;
283
284
        $this->view->title = $product->title;
285
        $this->view->blocks['announce'] = $product->announce;
286
        $this->view->blocks['content'] = $product->content;
287
        $this->view->blocks['title'] = $product->title;
288
289
290
        return $this->render(
291
            $this->computeViewFile($product, 'show'),
292
            [
293
                'model' => $product,
294
                'category_group_id' => $category_group_id,
295
                'values_by_property_id' => $values_by_property_id,
296
                'selected_category_id' => $selected_category_id,
297
                'selected_category' => $selected_category,
298
                'selected_category_ids' => $selected_category_ids,
299
                'object' => $object,
300
                'breadcrumbs' => $this->buildBreadcrumbsArray($selected_category, $product)
0 ignored issues
show
Bug introduced by
It seems like $selected_category defined by $selected_category_id > ...ted_category_id) : null on line 282 can be null; however, app\modules\shop\control...buildBreadcrumbsArray() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
301
            ]
302
        );
303
    }
304
305
    /**
306
     * Search handler
307
     * @return array
308
     * @throws ForbiddenHttpException
309
     */
310
    public function actionSearch()
311
    {
312
        $headers = Yii::$app->response->getHeaders();
313
        $headers->set('X-Robots-Tag', 'none');
314
        $headers->set('X-Frame-Options', 'SAMEORIGIN');
315
        $headers->set('X-Content-Type-Options', 'nosniff');
316
        if (!Yii::$app->request->isAjax) {
317
            throw new ForbiddenHttpException();
318
        }
319
        $model = new Search();
320
        $model->load(Yii::$app->request->get());
321
        $cacheKey = 'ProductSearchIds: ' . $model->q;
322
        $ids = Yii::$app->cache->get($cacheKey);
323
        if ($ids === false) {
324
            $ids = ArrayHelper::merge(
325
                $model->searchProductsByDescription(),
326
                $model->searchProductsByProperty()
327
            );
328
            Yii::$app->cache->set(
329
                $cacheKey,
330
                $ids,
331
                86400,
332
                new TagDependency(
333
                    [
334
                        'tags' => ActiveRecordHelper::getCommonTag(Product::className()),
335
                    ]
336
                )
337
            );
338
        }
339
340
        /** @var \app\modules\shop\ShopModule $module */
341
        $module = Yii::$app->modules['shop'];
342
343
        $pages = new Pagination(
344
            [
345
                'defaultPageSize' => $module->searchResultsLimit,
346
                'forcePageParam' => false,
347
                'totalCount' => count($ids),
348
            ]
349
        );
350
        $cacheKey .= ' : ' . $pages->offset;
351
        $products = Yii::$app->cache->get($cacheKey);
352 View Code Duplication
        if ($products === false) {
353
            $products = Product::find()->where(
354
                [
355
                    'in',
356
                    '`id`',
357
                    array_slice(
358
                        $ids,
359
                        $pages->offset,
360
                        $pages->limit
361
                    )
362
                ]
363
            )->addOrderBy('sort_order')->with('images')->all();
364
            Yii::$app->cache->set(
365
                $cacheKey,
366
                $products,
367
                86400,
368
                new TagDependency(
369
                    [
370
                        'tags' => ActiveRecordHelper::getCommonTag(Product::className()),
371
                    ]
372
                )
373
            );
374
        }
375
        Yii::$app->response->format = Response::FORMAT_JSON;
376
        return [
377
            'view' => $this->renderAjax(
378
                'search',
379
                [
380
                    'model' => $model,
381
                    'pages' => $pages,
382
                    'products' => $products,
383
                ]
384
            ),
385
            'totalCount' => count($ids),
386
        ];
387
388
    }
389
390
    /**
391
    * This function build array for widget "Breadcrumbs"
392
    * @param Category $selCat - model of current category
393
    * @param Product|null $product - model of product, if current page is a page of product
394
    * @param array $properties - array of properties and static values
395
    * Return an array for widget or empty array
396
    */
397
    private function buildBreadcrumbsArray($selCat, $product = null, $properties = [])
398
    {
399
        if ($selCat === null) {
400
            return [];
401
        }
402
403
        // init
404
        $breadcrumbs = [];
405
        if ($product !== null) {
406
            $crumbs[$product->slug] = !empty($product->breadcrumbs_label) ? $product->breadcrumbs_label : '';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$crumbs was never initialized. Although not strictly required by PHP, it is generally a good practice to add $crumbs = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
407
        }
408
        $crumbs[$selCat->slug] = $selCat->breadcrumbs_label;
0 ignored issues
show
Bug introduced by
The variable $crumbs does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
409
410
        // get basic data
411
        $parent = $selCat->parent_id > 0 ? Category::findById($selCat->parent_id) : null;
412 View Code Duplication
        while ($parent !== null) {
413
            $crumbs[$parent->slug] = $parent->breadcrumbs_label;
414
            $parent = $parent->parent;
415
        }
416
417
        // build array for widget
418
        $url = '';
419
        $crumbs = array_reverse($crumbs, true);
420 View Code Duplication
        foreach ($crumbs as $slug => $label) {
421
            $url .= '/' . $slug;
422
            $breadcrumbs[] = [
423
                'label' => $label,
424
                'url' => $url
425
            ];
426
        }
427
        if (is_null($product) && $this->module->showFiltersInBreadcrumbs && !empty($properties)) {
428
            $route = [
429
                '@category',
430
                'last_category_id' => $selCat->id,
431
                'category_group_id' => $selCat->category_group_id,
432
            ];
433
            $params = [];
434
            foreach ($properties as $propertyId => $propertyStaticValues) {
435
                $localParams = $params;
436
                foreach ($propertyStaticValues as $propertyStaticValue) {
437
                    $psv = PropertyStaticValues::findById($propertyStaticValue);
438
                    if (is_null($psv)) {
439
                        continue;
440
                    }
441
                    $localParams[$propertyId][] = $propertyStaticValue;
442
                    $breadcrumbs[] = [
443
                        'label' => $psv['name'],
444
                        'url' => array_merge($route, ['properties' => $localParams]),
445
                    ];
446
                }
447
                $params[$propertyId] = $propertyStaticValues;
448
            }
449
        }
450
        unset($breadcrumbs[count($breadcrumbs) - 1]['url']); // last item is not a link
451
452
        if (isset(Yii::$app->response->blocks['breadcrumbs_label'])) {
453
            // last item label rewrited through prefiltered page or something similar
454
            $breadcrumbs[count($breadcrumbs) - 1]['label'] = Yii::$app->response->blocks['breadcrumbs_label'];
455
        }
456
457
        return $breadcrumbs;
458
    }
459
}
460