Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveParentDelegatingConstructorRector;
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
use Rector\Doctrine\Bundle230\Rector\Class_\AddAnnotationToRepositoryRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
Expand Down Expand Up @@ -44,7 +44,6 @@
'join' => 'join',
])
->withSkip([
AddAnnotationToRepositoryRector::class,
AddInstanceofAssertForNullableInstanceRector::class,
AssertEmptyNullableObjectToAssertInstanceofRector::class,
ClosureToArrowFunctionRector::class,
Expand All @@ -60,6 +59,7 @@
NullToStrictStringFuncCallArgRector::class,
PreferPHPUnitThisCallRector::class,
RemoveDeadInstanceOfRector::class,
RemoveParentDelegatingConstructorRector::class,
SimplifyIfElseToTernaryRector::class,
SimplifyIfReturnBoolRector::class,
ThrowWithPreviousExceptionRector::class,
Expand Down
10 changes: 5 additions & 5 deletions api/src/Entity/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
processor: ActivityCreateProcessor::class
),
],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
normalizationContext: ['groups' => ['read']]
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['camp'])]
#[ORM\Entity(repositoryClass: ActivityRepository::class)]
Expand Down Expand Up @@ -107,14 +107,14 @@ class Activity extends BaseEntity implements BelongsToCampInterface {
* The list of points in time when this activity's programme will be carried out.
*/
#[Assert\Valid]
#[AssertLastCollectionItemIsNotDeleted(groups: ['ScheduleEntry:delete'], message: 'Cannot delete the last schedule entry.')]
#[AssertLastCollectionItemIsNotDeleted(message: 'Cannot delete the last schedule entry.', groups: ['ScheduleEntry:delete'])]
#[Assert\Count(min: 1, groups: ['create'])]
#[ApiProperty(
writableLink: true,
example: [['period' => '/periods/1a2b3c4a', 'start' => '2023-05-01T15:00:00+00:00', 'end' => '2023-05-01T16:00:00+00:00']],
)]
#[Groups(['read', 'create'])]
#[ORM\OneToMany(targetEntity: ScheduleEntry::class, mappedBy: 'activity', orphanRemoval: true, cascade: ['persist'])]
#[ORM\OneToMany(targetEntity: ScheduleEntry::class, mappedBy: 'activity', cascade: ['persist'], orphanRemoval: true)]
#[ORM\OrderBy(['startOffset' => 'ASC', 'left' => 'ASC', 'endOffset' => 'DESC', 'id' => 'ASC'])]
public Collection $scheduleEntries;

Expand Down Expand Up @@ -184,8 +184,8 @@ class Activity extends BaseEntity implements BelongsToCampInterface {
*/
#[ApiProperty(
writable: false,
uriTemplate: Comment::ACTIVITY_SUBRESOURCE_URI_TEMPLATE,
example: '/activities/1a2b3c4d/comments'
example: '/activities/1a2b3c4d/comments',
uriTemplate: Comment::ACTIVITY_SUBRESOURCE_URI_TEMPLATE
)]
#[Groups(['read'])]
#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'activity')]
Expand Down
2 changes: 1 addition & 1 deletion api/src/Entity/ActivityProgressLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
validationContext: ['groups' => ['Default', 'create']]
),
],
denormalizationContext: ['groups' => ['write']],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
order: ['camp.id', 'position']
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['camp'])]
Expand Down
2 changes: 1 addition & 1 deletion api/src/Entity/ActivityResponsible.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
new Post(
securityPostDenormalize: 'is_granted("CAMP_MEMBER", object) or is_granted("CAMP_MANAGER", object) or object.activity === null'
), ],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
normalizationContext: ['groups' => ['read']]
)]
#[UniqueEntity(
fields: ['campCollaboration', 'activity'],
Expand Down
32 changes: 16 additions & 16 deletions api/src/Entity/Camp.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
processor: CampCreateProcessor::class,
),
],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
forceEager: false,
normalizationContext: ['groups' => ['read']]
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['isPrototype'])]
#[ApiFilter(filterClass: CampCollaboratorFilter::class)]
Expand Down Expand Up @@ -102,7 +102,7 @@ class Camp extends BaseEntity implements BelongsToCampInterface, CopyFromPrototy
example: [['description' => 'Hauptlager', 'start' => '2022-01-01', 'end' => '2022-01-08']]
)]
#[Groups(['read', 'create'])]
#[ORM\OneToMany(targetEntity: Period::class, mappedBy: 'camp', orphanRemoval: true, cascade: ['persist'])]
#[ORM\OneToMany(targetEntity: Period::class, mappedBy: 'camp', cascade: ['persist'], orphanRemoval: true)]
#[ORM\OrderBy(['start' => 'ASC'])]
public Collection $periods;

Expand All @@ -111,23 +111,23 @@ class Camp extends BaseEntity implements BelongsToCampInterface, CopyFromPrototy
*/
#[ApiProperty(
writable: false,
uriTemplate: Category::CAMP_SUBRESOURCE_URI_TEMPLATE,
example: '"/camp/1a2b3c4d/categories"'
example: '"/camp/1a2b3c4d/categories"',
uriTemplate: Category::CAMP_SUBRESOURCE_URI_TEMPLATE
)]
#[Groups(['read'])]
#[ORM\OneToMany(targetEntity: Category::class, mappedBy: 'camp', orphanRemoval: true, cascade: ['persist'])]
#[ORM\OneToMany(targetEntity: Category::class, mappedBy: 'camp', cascade: ['persist'], orphanRemoval: true)]
public Collection $categories;

/**
* All the progress labels within this camp.
*/
#[ApiProperty(
writable: false,
uriTemplate: ActivityProgressLabel::CAMP_SUBRESOURCE_URI_TEMPLATE,
example: '"/camps/1a2b3c4d/activity_progress_labels"'
example: '"/camps/1a2b3c4d/activity_progress_labels"',
uriTemplate: ActivityProgressLabel::CAMP_SUBRESOURCE_URI_TEMPLATE
)]
#[Groups(['read'])]
#[ORM\OneToMany(targetEntity: ActivityProgressLabel::class, mappedBy: 'camp', orphanRemoval: true, cascade: ['persist'])]
#[ORM\OneToMany(targetEntity: ActivityProgressLabel::class, mappedBy: 'camp', cascade: ['persist'], orphanRemoval: true)]
public Collection $progressLabels;

/**
Expand All @@ -136,8 +136,8 @@ class Camp extends BaseEntity implements BelongsToCampInterface, CopyFromPrototy
*/
#[ApiProperty(
writable: false,
uriTemplate: Activity::CAMP_SUBRESOURCE_URI_TEMPLATE,
example: '/camps/1a2b3c4d/activities'
example: '/camps/1a2b3c4d/activities',
uriTemplate: Activity::CAMP_SUBRESOURCE_URI_TEMPLATE
)]
#[Groups(['read'])]
#[ORM\OneToMany(targetEntity: Activity::class, mappedBy: 'camp', orphanRemoval: true)]
Expand All @@ -149,13 +149,13 @@ class Camp extends BaseEntity implements BelongsToCampInterface, CopyFromPrototy
*/
#[ApiProperty(writable: false, example: '["/material_lists/1a2b3c4d"]')]
#[Groups(['read'])]
#[ORM\OneToMany(targetEntity: MaterialList::class, mappedBy: 'camp', orphanRemoval: true, cascade: ['persist'])]
#[ORM\OneToMany(targetEntity: MaterialList::class, mappedBy: 'camp', cascade: ['persist'], orphanRemoval: true)]
public Collection $materialLists;

/**
* List of MaterialItems that belong to this Camp.
*/
#[ORM\OneToMany(targetEntity: MaterialItem::class, mappedBy: 'camp', orphanRemoval: true, cascade: ['persist'])]
#[ORM\OneToMany(targetEntity: MaterialItem::class, mappedBy: 'camp', cascade: ['persist'], orphanRemoval: true)]
public Collection $materialItems;

/**
Expand All @@ -164,7 +164,7 @@ class Camp extends BaseEntity implements BelongsToCampInterface, CopyFromPrototy
*/
#[ApiProperty(writable: false, uriTemplate: Checklist::CAMP_SUBRESOURCE_URI_TEMPLATE)]
#[Groups(['read'])]
#[ORM\OneToMany(targetEntity: Checklist::class, mappedBy: 'camp', orphanRemoval: true, cascade: ['persist'])]
#[ORM\OneToMany(targetEntity: Checklist::class, mappedBy: 'camp', cascade: ['persist'], orphanRemoval: true)]
public Collection $checklists;

/**
Expand Down Expand Up @@ -223,7 +223,7 @@ class Camp extends BaseEntity implements BelongsToCampInterface, CopyFromPrototy
*/
#[Assert\Type('bool')]
#[Assert\DisableAutoMapping]
#[ApiProperty(example: true, writable: false)]
#[ApiProperty(writable: false, example: true)]
#[Groups(['read'])]
#[ORM\Column(type: 'boolean')]
public bool $isPrototype = false;
Expand Down Expand Up @@ -485,8 +485,8 @@ public function getCamp(): ?Camp {
*/
#[ApiProperty(
writable: false,
uriTemplate: CampCollaboration::CAMP_SUBRESOURCE_URI_TEMPLATE,
example: '["/camps/1a2b3c4d/camp_collaborations"]'
example: '["/camps/1a2b3c4d/camp_collaborations"]',
uriTemplate: CampCollaboration::CAMP_SUBRESOURCE_URI_TEMPLATE
)]
public function getCampCollaborations(): array {
return [];
Expand Down
2 changes: 1 addition & 1 deletion api/src/Entity/CampCollaboration.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
processor: CampCollaborationCreateProcessor::class
),
],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
normalizationContext: ['groups' => ['read']]
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['camp', 'activityResponsibles.activity'])]
#[UniqueEntity(
Expand Down
2 changes: 1 addition & 1 deletion api/src/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
],
),
],
denormalizationContext: ['groups' => ['write']],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
order: ['camp.id', 'short'],
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['camp'])]
Expand Down
4 changes: 2 additions & 2 deletions api/src/Entity/Checklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
]
),
],
denormalizationContext: ['groups' => ['write']],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
order: ['camp.id', 'name'],
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['camp', 'isPrototype'])]
Expand Down Expand Up @@ -131,7 +131,7 @@ class Checklist extends BaseEntity implements BelongsToCampInterface, CopyFromPr
*/
#[Assert\Type('bool')]
#[Assert\DisableAutoMapping]
#[ApiProperty(example: true, writable: true)]
#[ApiProperty(writable: true, example: true)]
#[Groups(['read', 'create'])]
#[ORM\Column(type: 'boolean', options: ['default' => false])]
public bool $isPrototype = false;
Expand Down
2 changes: 1 addition & 1 deletion api/src/Entity/ChecklistItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
]
),
],
denormalizationContext: ['groups' => ['write']],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
order: ['checklist.id', 'id'],
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['checklist', 'checklist.camp', 'checklistNodes'])]
Expand Down
10 changes: 3 additions & 7 deletions api/src/Entity/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
security: 'is_fully_authenticated()',
),
],
denormalizationContext: ['groups' => ['write']],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
order: ['createTime' => 'ASC'],
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['camp', 'activity'])]
Expand Down Expand Up @@ -86,7 +86,7 @@ class Comment extends BaseEntity implements BelongsToCampInterface {
* The author of the comment.
*/
#[Assert\DisableAutoMapping] // avoids validation error when author is null in payload
#[ApiProperty(example: '/users/1a2b3c4d', writable: false)]
#[ApiProperty(writable: false, example: '/users/1a2b3c4d')]
#[Groups(['read', 'create'])]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'comments')]
#[ORM\JoinColumn(nullable: false, onDelete: 'cascade')]
Expand All @@ -112,15 +112,11 @@ class Comment extends BaseEntity implements BelongsToCampInterface {
#[InputFilter\Trim]
#[InputFilter\CleanText]
#[Assert\Length(max: 32)]
#[ApiProperty(example: 'Sportolympiade', writable: false)]
#[ApiProperty(writable: false, example: 'Sportolympiade')]
#[Groups(['read', 'create'])]
#[ORM\Column(type: 'text', nullable: true)]
public ?string $orphanDescription = null;

public function __construct() {
parent::__construct();
}

public function getCamp(): ?Camp {
return $this->camp;
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/Entity/ContentNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
provider: ContentNodeCollectionProvider::class
),
],
denormalizationContext: ['groups' => ['write']],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
order: ['root.id', 'parent.id', 'slot', 'position']
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['contentType', 'root'])]
Expand Down
4 changes: 2 additions & 2 deletions api/src/Entity/ContentNode/ChecklistNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
processor: ChecklistNodePersistProcessor::class,
),
],
denormalizationContext: ['groups' => ['write']],
routePrefix: '/content_node',
normalizationContext: ['groups' => ['read']],
routePrefix: '/content_node'
denormalizationContext: ['groups' => ['write']],
)]
#[ORM\Entity(repositoryClass: ChecklistNodeRepository::class)]
class ChecklistNode extends ContentNode {
Expand Down
4 changes: 2 additions & 2 deletions api/src/Entity/ContentNode/ColumnLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
processor: ContentNodePersistProcessor::class
),
],
denormalizationContext: ['groups' => ['write']],
routePrefix: '/content_node',
normalizationContext: ['groups' => ['read']],
routePrefix: '/content_node'
denormalizationContext: ['groups' => ['write']],
)]
#[ORM\Entity(repositoryClass: ColumnLayoutRepository::class)]
class ColumnLayout extends ContentNode implements SupportsContentNodeChildren {
Expand Down
6 changes: 3 additions & 3 deletions api/src/Entity/ContentNode/MaterialNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
processor: ContentNodePersistProcessor::class
),
],
denormalizationContext: ['groups' => ['write']],
routePrefix: '/content_node',
normalizationContext: ['groups' => ['read']],
routePrefix: '/content_node'
denormalizationContext: ['groups' => ['write']],
)]
#[ORM\Entity(repositoryClass: MaterialNodeRepository::class)]
class MaterialNode extends ContentNode {
#[ApiProperty(readableLink: true, writableLink: false)]
#[Groups(['read'])]
#[ORM\OneToMany(targetEntity: MaterialItem::class, mappedBy: 'materialNode', orphanRemoval: true, cascade: ['persist', 'remove'])]
#[ORM\OneToMany(targetEntity: MaterialItem::class, mappedBy: 'materialNode', cascade: ['persist', 'remove'], orphanRemoval: true)]
public Collection $materialItems;

public function __construct() {
Expand Down
4 changes: 2 additions & 2 deletions api/src/Entity/ContentNode/MultiSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
processor: MultiSelectCreateProcessor::class
),
],
denormalizationContext: ['groups' => ['write']],
routePrefix: '/content_node',
normalizationContext: ['groups' => ['read']],
routePrefix: '/content_node'
denormalizationContext: ['groups' => ['write']],
)]
#[ORM\Entity(repositoryClass: MultiSelectRepository::class)]
class MultiSelect extends ContentNode {
Expand Down
4 changes: 2 additions & 2 deletions api/src/Entity/ContentNode/ResponsiveLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
processor: ContentNodePersistProcessor::class
),
],
denormalizationContext: ['groups' => ['write']],
routePrefix: '/content_node',
normalizationContext: ['groups' => ['read']],
routePrefix: '/content_node'
denormalizationContext: ['groups' => ['write']],
)]
#[ORM\Entity(repositoryClass: ResponsiveLayoutRepository::class)]
class ResponsiveLayout extends ContentNode implements SupportsContentNodeChildren {
Expand Down
4 changes: 2 additions & 2 deletions api/src/Entity/ContentNode/SingleText.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
processor: SingleTextPersistProcessor::class
),
],
denormalizationContext: ['groups' => ['write']],
routePrefix: '/content_node',
normalizationContext: ['groups' => ['read']],
routePrefix: '/content_node'
denormalizationContext: ['groups' => ['write']],
)]
#[ORM\Entity(repositoryClass: SingleTextRepository::class)]
class SingleText extends ContentNode {
Expand Down
4 changes: 2 additions & 2 deletions api/src/Entity/ContentNode/Storyboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
processor: StoryboardPersistProcessor::class
),
],
denormalizationContext: ['groups' => ['write']],
routePrefix: '/content_node',
normalizationContext: ['groups' => ['read']],
routePrefix: '/content_node'
denormalizationContext: ['groups' => ['write']],
)]
#[ORM\Entity(repositoryClass: StoryboardRepository::class)]
class Storyboard extends ContentNode {
Expand Down
6 changes: 3 additions & 3 deletions api/src/Entity/Day.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
]
),
],
denormalizationContext: ['groups' => ['write']],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
order: ['period.start', 'dayOffset']
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['period', 'period.camp'])]
Expand Down Expand Up @@ -83,8 +83,8 @@ class Day extends BaseEntity implements BelongsToCampInterface {
*/
#[ApiProperty(
writable: false,
uriTemplate: DayResponsible::DAY_SUBRESOURCE_URI_TEMPLATE,
example: '/days/1a2b3c4d/day_responsibles'
example: '/days/1a2b3c4d/day_responsibles',
uriTemplate: DayResponsible::DAY_SUBRESOURCE_URI_TEMPLATE
)]
#[Groups(['read'])]
#[ORM\OneToMany(targetEntity: DayResponsible::class, mappedBy: 'day', orphanRemoval: true)]
Expand Down
Loading