|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Controller\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use App\Admin\Field\VichyFileField; |
|
6
|
|
|
use App\Entity\SEPAExport; |
|
7
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Action; |
|
8
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; |
|
9
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; |
|
10
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; |
|
11
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; |
|
12
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; |
|
13
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; |
|
14
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; |
|
15
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; |
|
16
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField; |
|
17
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; |
|
18
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; |
|
19
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; |
|
20
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; |
|
21
|
|
|
use PHP_CodeSniffer\Generators\Text; |
|
22
|
|
|
|
|
23
|
|
|
class SEPAExportCrudController extends AbstractCrudController |
|
24
|
|
|
{ |
|
25
|
|
|
public static function getEntityFqcn(): string |
|
26
|
|
|
{ |
|
27
|
|
|
return SEPAExport::class; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function configureCrud(Crud $crud): Crud |
|
31
|
|
|
{ |
|
32
|
|
|
return $crud |
|
33
|
|
|
->setEntityLabelInSingular('sepa_export.label') |
|
34
|
|
|
->showEntityActionsInlined() |
|
35
|
|
|
//->setSearchFields(['name', 'iban', 'bic', 'comment', 'account_name']) |
|
36
|
|
|
->setEntityLabelInPlural('sepa_export.labelp'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function configureActions(Actions $actions): Actions |
|
40
|
|
|
{ |
|
41
|
|
|
$actions->setPermissions([ |
|
42
|
|
|
Action::DETAIL => 'ROLE_SHOW_SEPA_EXPORTS', |
|
43
|
|
|
Action::INDEX => 'ROLE_SHOW_SEPA_EXPORTS', |
|
44
|
|
|
Action::EDIT => 'ROLE_EDIT_SEPA_EXPORTS', |
|
45
|
|
|
Action::DELETE => 'ROLE_EDIT_SEPA_EXPORTS', |
|
46
|
|
|
]); |
|
47
|
|
|
|
|
48
|
|
|
$actions->disable(Crud::PAGE_NEW); |
|
49
|
|
|
$actions->add(Crud::PAGE_INDEX, Action::DETAIL); |
|
50
|
|
|
|
|
51
|
|
|
return parent::configureActions($actions); // TODO: Change the autogenerated stub |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function configureFields(string $pageName): iterable |
|
55
|
|
|
{ |
|
56
|
|
|
$xml_file = VichyFileField::new('xml_file', 'sepa_export.xml_file'); |
|
57
|
|
|
$id = IdField::new('id', 'sepa_export.id'); |
|
58
|
|
|
$number_of_payments = NumberField::new('number_of_payments', 'sepa_export.number_of_payments'); |
|
59
|
|
|
$initiator_bic = TextField::new('initiator_bic', 'sepa_export.initiator_bic'); |
|
60
|
|
|
$initiator_iban = TextField::new('initiator_iban', 'sepa_export.initiator_iban'); |
|
61
|
|
|
$booking_date = DateTimeField::new('booking_date', 'sepa_export.booking_date'); |
|
62
|
|
|
$total_sum = MoneyField::new('total_sum', 'sepa_export.total_sum') |
|
63
|
|
|
->setCurrency('EUR') |
|
64
|
|
|
->setStoredAsCents(true); |
|
65
|
|
|
$sepa_message_id = TextField::new('sepa_message_id', 'sepa_export.message_id'); |
|
66
|
|
|
$description = TextField::new('description', 'sepa_export.description'); |
|
67
|
|
|
$comment = TextEditorField::new('comment', 'sepa_export.comment'); |
|
68
|
|
|
$group_ulid = TextField::new('group_ulid', 'sepa_export.group_ulid')->onlyOnDetail(); |
|
69
|
|
|
$last_modified = DateTimeField::new('last_modified', 'last_modified'); |
|
70
|
|
|
$creationDate = DateTimeField::new('creation_date', 'creation_date')->onlyOnDetail(); |
|
71
|
|
|
$associated_payment_orders = AssociationField::new('associated_payment_orders') |
|
72
|
|
|
->setTemplatePath('admin/field/sepa_export_association.html.twig') |
|
73
|
|
|
->setCrudController(PaymentOrderCrudController::class); |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
if (Crud::PAGE_INDEX === $pageName) { |
|
77
|
|
|
return [$id, $number_of_payments, $total_sum, $description, $initiator_iban, $booking_date]; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
if (Crud::PAGE_DETAIL === $pageName) { |
|
81
|
|
|
return [ |
|
82
|
|
|
$xml_file, |
|
83
|
|
|
|
|
84
|
|
|
FormField::addPanel('sepa_export.infos')->collapsible(), |
|
85
|
|
|
$id, |
|
86
|
|
|
$number_of_payments, |
|
87
|
|
|
$total_sum, |
|
88
|
|
|
$initiator_iban, |
|
89
|
|
|
$initiator_bic, |
|
90
|
|
|
$description, |
|
91
|
|
|
$booking_date, |
|
92
|
|
|
$associated_payment_orders, |
|
93
|
|
|
$comment, |
|
94
|
|
|
|
|
95
|
|
|
FormField::addPanel('sepa_export.advanced')->collapsible(), |
|
96
|
|
|
$sepa_message_id, |
|
97
|
|
|
$group_ulid, |
|
98
|
|
|
$last_modified, |
|
99
|
|
|
$creationDate, |
|
100
|
|
|
]; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
if (Crud::PAGE_EDIT === $pageName) { |
|
104
|
|
|
return [$comment]; |
|
105
|
|
|
} |
|
|
|
|
|
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: