ContentList::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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