-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDomainCrudController.php
More file actions
73 lines (64 loc) · 2.36 KB
/
Copy pathDomainCrudController.php
File metadata and controls
73 lines (64 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
declare(strict_types=1);
namespace App\Controller\Admin;
use App\Admin\Field\DomainField;
use App\Admin\Field\ServerTypeField;
use App\Admin\Field\SiteTypeField;
use App\Entity\Domain;
use App\Form\Type\Admin\ServerTypeFilter;
use App\Trait\ExportCrudControllerTrait;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
class DomainCrudController extends AbstractCrudController
{
use ExportCrudControllerTrait;
public static function getEntityFqcn(): string
{
return Domain::class;
}
#[\Override]
public function configureCrud(Crud $crud): Crud
{
return $crud->showEntityActionsInlined();
}
#[\Override]
public function configureActions(Actions $actions): Actions
{
return $actions
->add(Crud::PAGE_INDEX, Action::DETAIL)
->add(Crud::PAGE_INDEX, $this->createExportAction())
->remove(Crud::PAGE_INDEX, Action::NEW)
->remove(Crud::PAGE_INDEX, Action::EDIT)
->remove(Crud::PAGE_INDEX, Action::DELETE)
->remove(Crud::PAGE_DETAIL, Action::EDIT)
->remove(Crud::PAGE_DETAIL, Action::DELETE)
;
}
#[\Override]
public function configureFields(string $pageName): iterable
{
yield DomainField::new('address')->setColumns(12);
yield SiteTypeField::new('site.type')->hideOnIndex();
yield AssociationField::new('site')->hideOnIndex();
yield ServerTypeField::new('server.type')->setLabel('Type')->setSortable(true);
yield AssociationField::new('server');
yield AssociationField::new('detectionResult')->hideOnIndex();
yield DateTimeField::new('createdAt')->hideOnIndex();
yield DateTimeField::new('detectionResult.lastContact')->hideOnIndex();
}
#[\Override]
public function configureFilters(Filters $filters): Filters
{
return $filters
->add('address')
->add('site')
->add('server')
->add(ServerTypeFilter::new('server.type', 'Server type'))
;
}
}