-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathStandaloneMethodsCrudController.php
More file actions
65 lines (59 loc) · 1.8 KB
/
StandaloneMethodsCrudController.php
File metadata and controls
65 lines (59 loc) · 1.8 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
<?php
namespace EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\AdminRouteApp\Controller;
use EasyCorp\Bundle\EasyAdminBundle\Attribute\AdminRoute;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\AdminRouteApp\Entity\Product;
use Symfony\Component\HttpFoundation\Response;
/**
* Test case 5: CRUD controller with only method-level routes (no class-level attribute).
*/
class StandaloneMethodsCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Product::class;
}
#[AdminRoute(
path: '/crud/action1',
name: 'crud_action1'
)]
public function action1(): Response
{
return new Response('Standalone CRUD Action 1');
}
#[AdminRoute(
path: '/crud/action2',
name: 'crud_action2',
options: ['methods' => ['POST']]
)]
public function action2(): Response
{
return new Response('Standalone CRUD Action 2');
}
#[AdminRoute(
path: '/crud/action3/{entityId}',
name: 'crud_action3',
options: [
'requirements' => [
'entityId' => '\d+',
],
'options' => [
'compiler_class' => 'Symfony\Component\Routing\RouteCompiler',
],
'defaults' => [
'foo' => 'bar',
],
'host' => 'admin.example.com',
'schemes' => 'https',
'condition' => 'context.getMethod() in ["GET", "HEAD"]',
'locale' => 'en',
'format' => 'html',
'utf8' => true,
'stateless' => true,
]
)]
public function action3(): Response
{
return new Response('Standalone CRUD Action 3');
}
}