|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
/** |
|
5
|
|
|
* This file is part of the mailserver-admin package. |
|
6
|
|
|
* (c) Jeffrey Boehm <https://github.com/jeboehm/mailserver-admin> |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace App\Controller\Admin; |
|
12
|
|
|
|
|
13
|
|
|
use App\Entity\Domain; |
|
14
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; |
|
15
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; |
|
16
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; |
|
17
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; |
|
18
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; |
|
19
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; |
|
20
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; |
|
21
|
|
|
|
|
22
|
|
|
class DomainCrudController extends AbstractCrudController |
|
23
|
|
|
{ |
|
24
|
|
|
public static function getEntityFqcn(): string |
|
25
|
|
|
{ |
|
26
|
|
|
return Domain::class; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function configureCrud(Crud $crud): Crud |
|
30
|
|
|
{ |
|
31
|
|
|
return $crud->setSearchFields(['name']); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function configureFields(string $pageName): iterable |
|
35
|
|
|
{ |
|
36
|
|
|
$name = TextField::new('name'); |
|
37
|
|
|
$id = IdField::new('id', 'ID'); |
|
38
|
|
|
$dkimEnabled = BooleanField::new('dkimEnabled'); |
|
39
|
|
|
$dkimSelector = TextField::new('dkimSelector'); |
|
40
|
|
|
$dkimPrivateKey = TextareaField::new('dkimPrivateKey'); |
|
41
|
|
|
$users = AssociationField::new('users'); |
|
42
|
|
|
$aliases = AssociationField::new('aliases'); |
|
43
|
|
|
|
|
44
|
|
|
if (Crud::PAGE_DETAIL === $pageName) { |
|
45
|
|
|
return [$id, $name, $dkimEnabled, $dkimSelector, $dkimPrivateKey, $users, $aliases]; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
if (Crud::PAGE_NEW === $pageName) { |
|
49
|
|
|
return [$name]; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
if (Crud::PAGE_EDIT === $pageName) { |
|
53
|
|
|
return [$name]; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
return [$name, $aliases, $users]; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|