Actions   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareDataSource() 0 18 3
A __construct() 0 9 1
1
<?php
2
3
namespace Tkotosz\CommandScheduler\Ui\Component\Listing\Columns;
4
5
use Magento\Framework\View\Element\UiComponent\ContextInterface;
6
use Magento\Framework\View\Element\UiComponentFactory;
7
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...
8
use Magento\Framework\UrlInterface;
9
10
class Actions extends Column
11
{
12
    /**
13
     * @var UrlInterface
14
     */
15
    protected $urlBuilder;
16
17
    /**
18
     * @param ContextInterface   $context
19
     * @param UiComponentFactory $uiComponentFactory
20
     * @param UrlInterface       $urlBuilder
21
     * @param array              $components
22
     * @param array              $data
23
     */
24
    public function __construct(
25
        ContextInterface $context,
26
        UiComponentFactory $uiComponentFactory,
27
        UrlInterface $urlBuilder,
28
        array $components = [],
29
        array $data = []
30
    ) {
31
        $this->urlBuilder = $urlBuilder;
32
        parent::__construct($context, $uiComponentFactory, $components, $data);
33
    }
34
35
    /**
36
     * Prepare Data Source
37
     *
38
     * @param array $dataSource
39
     *
40
     * @return array
41
     */
42
    public function prepareDataSource(array $dataSource)
43
    {
44
        if (!isset($dataSource['data']['items'])) {
45
            return $dataSource;
46
        }
47
48
        foreach ($dataSource['data']['items'] as &$item) {
49
            $item[$this->getData('name')]['edit'] = [
50
                'href'   => $this->urlBuilder->getUrl(
51
                    'tkotosz_commandscheduler/schedule/viewresult',
52
                    ['id' => $item['schedule_id']]
53
                ),
54
                'label'  => __('View Result'),
55
                'hidden' => false
56
            ];
57
        }
58
59
        return $dataSource;
60
    }
61
}
62