|
5 | 5 | use ApiPlatform\Core\Annotation\ApiProperty;
|
6 | 6 | use ApiPlatform\Core\Annotation\ApiResource;
|
7 | 7 | use App\Entity\ContentNode;
|
| 8 | +use App\Repository\ColumnLayoutRepository; |
8 | 9 | use App\Validator\AssertJsonSchema;
|
9 | 10 | use App\Validator\ColumnLayout\AssertColumWidthsSumTo12;
|
10 | 11 | use App\Validator\ColumnLayout\AssertNoOrphanChildren;
|
11 |
| -use App\Validator\ColumnLayout\ColumnLayoutGroupSequence; |
| 12 | +use App\Validator\ColumnLayout\ColumnLayoutPatchGroupSequence; |
| 13 | +use App\Validator\ColumnLayout\ColumnLayoutPostGroupSequence; |
12 | 14 | use Doctrine\ORM\Mapping as ORM;
|
13 | 15 | use Symfony\Component\Serializer\Annotation\Groups;
|
14 | 16 |
|
15 | 17 | /**
|
16 |
| - * @ORM\Entity |
| 18 | + * @ORM\Entity(repositoryClass=ColumnLayoutRepository::class) |
17 | 19 | * @ORM\Table(name="content_node_columnlayout")
|
18 | 20 | */
|
19 | 21 | #[ApiResource(
|
|
25 | 27 | 'post' => [
|
26 | 28 | 'denormalization_context' => ['groups' => ['write', 'create']],
|
27 | 29 | 'security_post_denormalize' => 'is_granted("CAMP_MEMBER", object) or is_granted("CAMP_MANAGER", object)',
|
28 |
| - 'validation_groups' => ColumnLayoutGroupSequence::class, |
| 30 | + 'validation_groups' => ColumnLayoutPostGroupSequence::class, |
29 | 31 | ],
|
30 | 32 | ],
|
31 | 33 | itemOperations: [
|
32 | 34 | 'get' => ['security' => 'is_granted("CAMP_COLLABORATOR", object) or is_granted("CAMP_IS_PROTOTYPE", object)'],
|
33 | 35 | 'patch' => [
|
34 | 36 | 'denormalization_context' => ['groups' => ['write', 'update']],
|
35 | 37 | 'security' => 'is_granted("CAMP_MEMBER", object) or is_granted("CAMP_MANAGER", object)',
|
36 |
| - 'validation_groups' => ColumnLayoutGroupSequence::class, |
| 38 | + 'validation_groups' => ColumnLayoutPatchGroupSequence::class, |
37 | 39 | ],
|
38 |
| - 'delete' => ['security' => 'is_granted("CAMP_MEMBER", object) or is_granted("CAMP_MANAGER", object)'], |
| 40 | + 'delete' => ['security' => '(is_granted("CAMP_MEMBER", object) or is_granted("CAMP_MANAGER", object)) and object.owner === null'], // disallow delete when contentNode is a root node |
39 | 41 | ],
|
40 | 42 | denormalizationContext: ['groups' => ['write']],
|
41 | 43 | normalizationContext: ['groups' => ['read']],
|
|
0 commit comments