Skip to content

Commit 59d1ae9

Browse files
committed
fix: add missing expand relation on add on serializer
added sponsorship
1 parent 589e1a4 commit 59d1ae9

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

app/ModelSerializers/Summit/SummitSponsorshipAddOnSerializer.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace App\ModelSerializers\Summit;
22

3+
use Libs\ModelSerializers\One2ManyExpandSerializer;
34
use ModelSerializers\SilverStripeSerializer;
45

56
/**
@@ -23,6 +24,16 @@ final class SummitSponsorshipAddOnSerializer extends SilverStripeSerializer
2324
{
2425
protected static $array_mappings = [
2526
'Name' => 'name:json_string',
26-
'Type' => 'type:json_string'
27+
'Type' => 'type:json_string',
28+
'SponsorshipId' => 'sponsorship_id:json_int',
2729
];
28-
}
30+
31+
protected static $expand_mappings = [
32+
'sponsorship' => [
33+
'type' => One2ManyExpandSerializer::class,
34+
'original_attribute' => 'sponsorship_id',
35+
'getter' => 'getSponsorship',
36+
'has' => 'hasSponsorship'
37+
],
38+
];
39+
}

app/Models/Foundation/Summit/SummitSponsorshipAddOn.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use App\Repositories\Summit\DoctrineSummitSponsorshipAddOnRepository;
1616
use Doctrine\ORM\Mapping as ORM;
1717
use models\exceptions\ValidationException;
18+
use models\utils\One2ManyPropertyTrait;
1819
use models\utils\SilverstripeBaseModel;
1920

2021
/**
@@ -24,6 +25,17 @@
2425
#[ORM\Entity(repositoryClass: DoctrineSummitSponsorshipAddOnRepository::class)]
2526
class SummitSponsorshipAddOn extends SilverstripeBaseModel
2627
{
28+
29+
use One2ManyPropertyTrait;
30+
31+
protected $getIdMappings = [
32+
'getSponsorshipId' => 'sponsorship',
33+
];
34+
35+
protected $hasPropertyMappings = [
36+
'hasSponsorship' => 'sponsorship',
37+
];
38+
2739
const Booth_Type = 'Booth';
2840
const MeetingRoom_Type = 'Meeting_Room';
2941
const ScheduleSpot_Type = 'Schedule_Spot';
@@ -99,4 +111,4 @@ public function clearSponsorship(): void
99111
{
100112
$this->sponsorship = null;
101113
}
102-
}
114+
}

0 commit comments

Comments
 (0)