forked from ecamp/ecamp3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: use uriTemplate feature for Camp -> Profile relation
To omit the additional queries to each profile of each campCollaboration.
- Loading branch information
Showing
4 changed files
with
130 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\Get; | ||
use ApiPlatform\Metadata\GetCollection; | ||
use ApiPlatform\Metadata\Link; | ||
use ApiPlatform\Metadata\Patch; | ||
use App\InputFilter; | ||
use App\Repository\ProfileRepository; | ||
|
@@ -34,6 +35,13 @@ | |
new GetCollection( | ||
security: 'is_authenticated()' | ||
), | ||
new GetCollection( | ||
uriTemplate: self::CAMP_FILTER_URI_TEMPLATE, | ||
uriVariables: [ | ||
'campIri' => new Link(toProperty: 'user.collaborations.camp', fromClass: Camp::class), | ||
], | ||
security: 'is_authenticated()' | ||
), | ||
], | ||
denormalizationContext: ['groups' => ['write']], | ||
normalizationContext: ['groups' => ['read']] | ||
|
@@ -42,6 +50,8 @@ | |
#[ORM\Entity(repositoryClass: ProfileRepository::class)] | ||
#[ORM\Table(name: '`profile`')] | ||
class Profile extends BaseEntity { | ||
public const CAMP_FILTER_URI_TEMPLATE = '/profiles/user.collaborations.camp={campIri}'; | ||
|
||
public const EXAMPLE_EMAIL = '[email protected]'; | ||
public const EXAMPLE_FIRSTNAME = 'Robert'; | ||
public const EXAMPLE_SURNAME = 'Baden-Powell'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters