Passed
Push — master ( cbe288...130872 )
by Peter
02:31
created

PageCategory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 70
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

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