forked from sofascore/purgatory-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostController.php
More file actions
81 lines (75 loc) · 2.58 KB
/
Copy pathPostController.php
File metadata and controls
81 lines (75 loc) · 2.58 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
74
75
76
77
78
79
80
81
<?php
declare(strict_types=1);
namespace Sofascore\PurgatoryBundle\Tests\Functional\DebugCommand\Controller;
use Sofascore\PurgatoryBundle\Attribute\PurgeOn;
use Sofascore\PurgatoryBundle\Attribute\RouteParamValue\CompoundValues;
use Sofascore\PurgatoryBundle\Attribute\RouteParamValue\DynamicValues;
use Sofascore\PurgatoryBundle\Attribute\RouteParamValue\EnumValues;
use Sofascore\PurgatoryBundle\Attribute\RouteParamValue\RawValues;
use Sofascore\PurgatoryBundle\Attribute\Target\ForGroups;
use Sofascore\PurgatoryBundle\Listener\Enum\Action;
use Sofascore\PurgatoryBundle\Tests\Functional\DebugCommand\Entity\Author;
use Sofascore\PurgatoryBundle\Tests\Functional\DebugCommand\Entity\Post;
use Sofascore\PurgatoryBundle\Tests\Functional\DebugCommand\Entity\Tag;
use Sofascore\PurgatoryBundle\Tests\Functional\DebugCommand\Enum\LanguageCodes;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Annotation\Route as AnnotationRoute;
use Symfony\Component\Routing\Attribute\Route;
#[AsController]
#[Route('/post')]
#[AnnotationRoute('/post')]
class PostController
{
#[Route('/{post_id}', 'post_show')]
#[AnnotationRoute('/{post_id}', name: 'post_show')]
#[PurgeOn(Post::class,
routeParams: [
'post_id' => 'id',
],
if: 'obj.isActive() === true',
)]
#[PurgeOn(Author::class,
target: new ForGroups('common'),
routeParams: [
'post_id' => 'posts[*].id',
],
actions: [Action::Update, Action::Delete],
)]
public function show(Post $post): void
{
}
#[Route('/{lang}/{page}', 'post_list')]
#[AnnotationRoute('/{lang}/{page}', name: 'post_list')]
#[PurgeOn(Post::class,
target: new ForGroups('common'),
routeParams: [
'lang' => new CompoundValues(
new EnumValues(LanguageCodes::class),
new RawValues('XK'), // Kosovo
),
'page' => new DynamicValues('purgatory.get_page'),
],
)]
public function list(): void
{
}
#[Route('/{author_id}/{tag_id}', 'post_filter')]
#[AnnotationRoute('/{author_id}/{tag_id}', name: 'post_filter')]
#[PurgeOn(Author::class,
target: new ForGroups('common'),
routeParams: [
'author_id' => 'id',
'tag_id' => 'posts[*].tags[*].id',
],
)]
#[PurgeOn(Tag::class,
target: 'name',
routeParams: [
'author_id' => 'posts[*].author.id',
'tag_id' => 'id',
],
)]
public function filterByAuthorAndTag(Author $author): void
{
}
}