FaqGroupActions::prepareDataSource()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 21
rs 9.9332
c 1
b 0
f 0
cc 4
nc 2
nop 1
1
<?php
2
/**
3
 * MagePrince
4
 *
5
 * NOTICE OF LICENSE
6
 *
7
 * This source file is subject to the mageprince.com license that is
8
 * available through the world-wide-web at this URL:
9
 * https://mageprince.com/end-user-license-agreement
10
 *
11
 * DISCLAIMER
12
 *
13
 * Do not edit or add to this file if you wish to upgrade this extension to newer
14
 * version in the future.
15
 *
16
 * @category    MagePrince
17
 * @package     Mageprince_Faq
18
 * @copyright   Copyright (c) MagePrince (https://mageprince.com/)
19
 * @license     https://mageprince.com/end-user-license-agreement
20
 */
21
22
namespace Mageprince\Faq\Ui\Component\Listing\Column;
23
24
use Magento\Framework\UrlInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\UrlInterface 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
use Magento\Framework\View\Element\UiComponent\ContextInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\View\E...ponent\ContextInterface 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...
26
use Magento\Framework\View\Element\UiComponentFactory;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\View\Element\UiComponentFactory 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...
27
use Magento\Ui\Component\Listing\Columns\Column;
0 ignored issues
show
Bug introduced by
The type Magento\Ui\Component\Listing\Columns\Column 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...
28
29
class FaqGroupActions extends Column
30
{
31
    /**
32
     * @var UrlInterface
33
     */
34
    private $urlBuilder;
35
36
    /**
37
     * Faq group edit url path
38
     */
39
    private const URL_PATH_EDIT = 'mageprince_faq/faqgroup/edit';
40
41
    /**
42
     * FaqGroupActions constructor.
43
     * @param ContextInterface $context
44
     * @param UiComponentFactory $uiComponentFactory
45
     * @param UrlInterface $urlBuilder
46
     * @param array $components
47
     * @param array $data
48
     */
49
    public function __construct(
50
        ContextInterface $context,
51
        UiComponentFactory $uiComponentFactory,
52
        UrlInterface $urlBuilder,
53
        array $components = [],
54
        array $data = []
55
    ) {
56
        $this->urlBuilder = $urlBuilder;
57
        parent::__construct($context, $uiComponentFactory, $components, $data);
58
    }
59
60
    /**
61
     * Prepare Data Source
62
     *
63
     * @param array $dataSource
64
     * @return array
65
     */
66
    public function prepareDataSource(array $dataSource)
67
    {
68
        if (isset($dataSource['data']['items'])) {
69
            foreach ($dataSource['data']['items'] as & $item) {
70
                if (isset($item['faqgroup_id'])) {
71
                    $item[$this->getData('name')] = [
72
                        'edit' => [
73
                            'href' => $this->urlBuilder->getUrl(
74
                                static::URL_PATH_EDIT,
75
                                [
76
                                    'faqgroup_id' => $item['faqgroup_id']
77
                                ]
78
                            ),
79
                            'label' => __('Edit')
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

79
                            'label' => /** @scrutinizer ignore-call */ __('Edit')
Loading history...
80
                        ]
81
                    ];
82
                }
83
            }
84
        }
85
86
        return $dataSource;
87
    }
88
}
89