Passed
Push — master ( bf42cc...349842 )
by Peter
05:57
created

Form::__construct()   A

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