File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<?php namespace App \ModelSerializers \Summit ;
22
3+ use Libs \ModelSerializers \One2ManyExpandSerializer ;
34use 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+ }
Original file line number Diff line number Diff line change 1515use App \Repositories \Summit \DoctrineSummitSponsorshipAddOnRepository ;
1616use Doctrine \ORM \Mapping as ORM ;
1717use models \exceptions \ValidationException ;
18+ use models \utils \One2ManyPropertyTrait ;
1819use models \utils \SilverstripeBaseModel ;
1920
2021/**
2425#[ORM \Entity(repositoryClass: DoctrineSummitSponsorshipAddOnRepository::class)]
2526class 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+ }
You can’t perform that action at this time.
0 commit comments