Form::getGetters()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Contact\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\Contact\Constant\Route;
11
use AbterPhp\Contact\Grid\Factory\Table\Form as TableFactory;
12
use AbterPhp\Contact\Grid\Factory\Table\Header\Form as HeaderFactory;
13
use AbterPhp\Contact\Grid\Filters\Form as Filters;
14
use AbterPhp\Framework\Constant\Html5;
15
use AbterPhp\Framework\Grid\Action\Action;
16
use AbterPhp\Framework\Grid\Component\Actions;
17
use Opulence\Routing\Urls\UrlGenerator;
18
19
class Form extends BaseFactory
20
{
21
    private const GETTER_IDENTIFIER = 'getIdentifier';
22
    private const GETTER_TO_NAME    = 'getToName';
23
    private const GETTER_TO_EMAIL   = 'getToEmail';
24
25
    /**
26
     * Form constructor.
27
     *
28
     * @param UrlGenerator      $urlGenerator
29
     * @param PaginationFactory $paginationFactory
30
     * @param TableFactory      $tableFactory
31
     * @param GridFactory       $gridFactory
32
     * @param Filters           $filters
33
     */
34
    public function __construct(
35
        UrlGenerator $urlGenerator,
36
        PaginationFactory $paginationFactory,
37
        TableFactory $tableFactory,
38
        GridFactory $gridFactory,
39
        Filters $filters
40
    ) {
41
        parent::__construct($urlGenerator, $paginationFactory, $tableFactory, $gridFactory, $filters);
42
    }
43
44
    /**
45
     * @return array
46
     */
47
    public function getGetters(): array
48
    {
49
        return [
50
            HeaderFactory::GROUP_IDENTIFIER => static::GETTER_IDENTIFIER,
51
            HeaderFactory::GROUP_TO_NAME    => static::GETTER_TO_NAME,
52
            HeaderFactory::GROUP_TO_EMAIL   => static::GETTER_TO_EMAIL,
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 => Route::CONTACT_FORMS_EDIT,
65
        ];
66
67
        $deleteAttributes = [
68
            Html5::ATTR_HREF => Route::CONTACT_FORMS_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