Passed
Pull Request — master (#1)
by Peter
02:52
created

ContentList::getRowActions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 19
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 28
rs 9.6333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Website\Grid\Factory;
6
7
use AbterPhp\Admin\Grid\Factory\BaseFactory;
8
use AbterPhp\Admin\Grid\Factory\GridFactory;
9
use AbterPhp\Admin\Grid\Factory\PaginationFactory;
10
use AbterPhp\Framework\Constant\Html5;
11
use AbterPhp\Framework\Grid\Action\Action;
12
use AbterPhp\Framework\Grid\Component\Actions;
13
use AbterPhp\Website\Constant\Routes;
14
use AbterPhp\Website\Grid\Factory\Table\ContentList as TableFactory;
15
use AbterPhp\Website\Grid\Filters\ContentList as Filters;
16
use Opulence\Routing\Urls\UrlGenerator;
17
18
class ContentList extends BaseFactory
19
{
20
    const GROUP_IDENTIFIER = 'contentList-identifier';
21
    const GROUP_NAME       = 'contentList-name';
22
23
    const GETTER_IDENTIFIER = 'getIdentifier';
24
    const GETTER_NAME       = 'getName';
25
26
    /**
27
     * ContentList constructor.
28
     *
29
     * @param UrlGenerator      $urlGenerator
30
     * @param PaginationFactory $paginationFactory
31
     * @param TableFactory      $tableFactory
32
     * @param GridFactory       $gridFactory
33
     * @param Filters           $blockFilters
34
     */
35
    public function __construct(
36
        UrlGenerator $urlGenerator,
37
        PaginationFactory $paginationFactory,
38
        TableFactory $tableFactory,
39
        GridFactory $gridFactory,
40
        Filters $blockFilters
41
    ) {
42
        parent::__construct($urlGenerator, $paginationFactory, $tableFactory, $gridFactory, $blockFilters);
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function getGetters(): array
49
    {
50
        return [
51
            static::GROUP_IDENTIFIER => static::GETTER_IDENTIFIER,
52
            static::GROUP_NAME       => static::GETTER_NAME,
53
        ];
54
    }
55
56
    /**
57
     * @return Actions
58
     */
59
    protected function getRowActions(): Actions
60
    {
61
        $attributeCallbacks = $this->getAttributeCallbacks();
62
63
        $editAttributes   = [
64
            Html5::ATTR_HREF => Routes::ROUTE_CONTENT_LISTS_EDIT,
65
        ];
66
        $deleteAttributes = [
67
            Html5::ATTR_HREF => Routes::ROUTE_CONTENT_LISTS_DELETE,
68
        ];
69
70
        $cellActions   = new Actions();
71
        $cellActions[] = new Action(
72
            static::LABEL_EDIT,
73
            $this->editIntents,
74
            $editAttributes,
75
            $attributeCallbacks,
76
            Html5::TAG_A
77
        );
78
        $cellActions[] = new Action(
79
            static::LABEL_DELETE,
80
            $this->deleteIntents,
81
            $deleteAttributes,
82
            $attributeCallbacks,
83
            Html5::TAG_A
84
        );
85
86
        return $cellActions;
87
    }
88
}
89