@@ -641,56 +641,15 @@ private function canPerformEventTypeTransition(SummitEventType $old_event_type,
641641 */
642642 private function saveOrUpdateEvent (Summit $ summit , array $ data , $ event_id = null )
643643 {
644-
645-
646- // check first if there is an upgrade or not
647-
648- $ res = $ this ->tx_service ->transaction (function () use ($ summit , $ data , $ event_id ) {
649- $ event_type = null ;
650- if (isset ($ data ['type_id ' ])) {
651- $ event_type = $ summit ->getEventType (intval ($ data ['type_id ' ]));
652- if (is_null ($ event_type )) {
653- throw new EntityNotFoundException (sprintf ("event type id %s does not exists! " , $ data ['type_id ' ]));
654- }
655- }
656-
657- if (!is_null ($ event_id ) && $ event_id > 0 ) {
658- $ event = $ this ->event_repository ->getByIdRefreshed ($ event_id );
659- if (is_null ($ event ))
660- throw new ValidationException (sprintf ("event id %s does not exists! " , $ event_id ));
661- $ old_event_type = $ event ->getType ();
662-
663- // check event type transition ...
664-
665- if (!is_null ($ event_type )) {
666-
667- if ($ old_event_type ->getClassName () != $ event_type ->getClassName () && $ event_type instanceof PresentationType) {
668- Log::debug (sprintf ("SummitService::saveOrUpdateEvent promoting event %s 2 presentation ... " , $ event_id ));
669- $ event ->promote2Presentation ($ event_type );
670- return $ event ;
671- }
672- }
673- }
674- return null ;
675- });
676-
677- // we performed an upgrade, return the event
678- if (!is_null ($ res ))
679- {
680- return $ this ->tx_service ->transaction (function () use ($ summit , $ data , $ event_id ) {
681- return $ this ->event_repository ->getByIdRefreshed ($ event_id );
682- });
683- }
684-
685644 return $ this ->tx_service ->transaction (function () use ($ summit , $ data , $ event_id ) {
686645
687646 Log::debug
688647 (
689648 sprintf
690649 (
691650 "SummitService::saveOrUpdateEvent summit %s event_id %s data %s " ,
692- $ summit ->getId () ,
693- $ event_id ?? "NEW " ,
651+ $ summit ->getId (),
652+ $ event_id ?? "NEW " ,
694653 json_encode ($ data )
695654 )
696655 );
@@ -738,16 +697,16 @@ private function saveOrUpdateEvent(Summit $summit, array $data, $event_id = null
738697 // check event type transition ...
739698
740699 if (!is_null ($ event_type ) && !$ this ->canPerformEventTypeTransition ($ old_event_type , $ event_type )) {
741- throw new ValidationException
700+ throw new ValidationException
701+ (
702+ sprintf
742703 (
743- sprintf
744- (
745- "invalid event type transition for event id %s ( from %s to %s) " ,
746- $ event_id ,
747- $ old_event_type ->getType (),
748- $ event_type ->getType ()
749- )
750- );
704+ "invalid event type transition for event id %s ( from %s to %s) " ,
705+ $ event_id ,
706+ $ old_event_type ->getType (),
707+ $ event_type ->getType ()
708+ )
709+ );
751710 }
752711 if (is_null ($ event_type )) $ event_type = $ old_event_type ;
753712 }
@@ -861,7 +820,7 @@ private function saveOrUpdateEvent(Summit $summit, array $data, $event_id = null
861820 $ opening_hour = null ;
862821 $ closing_hour = null ;
863822
864- if (!is_null ($ location )){
823+ if (!is_null ($ location )) {
865824 $ opening_hour = $ location ->getOpeningHour ();
866825 $ closing_hour = $ location ->getClosingHour ();
867826 }
@@ -1013,7 +972,7 @@ public function publishEvent(Summit $summit, $event_id, array $data): SummitEven
1013972 $ opening_hour = null ;
1014973 $ closing_hour = null ;
1015974
1016- if (!is_null ($ location )){
975+ if (!is_null ($ location )) {
1017976 $ opening_hour = $ location ->getOpeningHour ();
1018977 $ closing_hour = $ location ->getClosingHour ();
1019978 }
@@ -1641,7 +1600,7 @@ public function updateSummit($summit_id, array $data)
16411600
16421601 $ old_summit = $ this ->summit_repository ->getBySlug (trim ($ slug ));
16431602 if (!is_null ($ old_summit ) && $ summit_id != $ old_summit ->getId ()) {
1644- throw new ValidationException (sprintf ("Slug %s already belongs to another summit (%s)/ " , $ slug ,$ old_summit ->getId ()));
1603+ throw new ValidationException (sprintf ("Slug %s already belongs to another summit (%s)/ " , $ slug , $ old_summit ->getId ()));
16451604 }
16461605 }
16471606
@@ -1651,7 +1610,7 @@ public function updateSummit($summit_id, array $data)
16511610
16521611 $ old_summit =
16531612 $ this ->summit_repository ->getByRegistrationSlugPrefix (Summit::formatSlug ($ registration_slug_prefix ));
1654- if (!is_null ($ old_summit ) && $ summit_id != $ old_summit ->getId () ) {
1613+ if (!is_null ($ old_summit ) && $ summit_id != $ old_summit ->getId ()) {
16551614 throw new ValidationException (sprintf (
16561615 "Registration slug prefix %s already belongs to summit (%s). " ,
16571616 $ registration_slug_prefix , $ old_summit ->getId ()
@@ -1751,7 +1710,7 @@ public function addSpeaker2Presentation(int $current_member_id, int $speaker_id,
17511710
17521711 $ selection_plan = $ presentation ->getSelectionPlan ();
17531712
1754- if (!is_null ($ selection_plan ) && $ selection_plan ->isPrivate () && !$ selection_plan ->containsMember ($ speaker ->getEmail ())){
1713+ if (!is_null ($ selection_plan ) && $ selection_plan ->isPrivate () && !$ selection_plan ->containsMember ($ speaker ->getEmail ())) {
17551714 $ selection_plan ->addAllowedMember ($ speaker ->getEmail ());
17561715 }
17571716
@@ -1853,7 +1812,7 @@ public function addModerator2Presentation(int $current_member_id, int $speaker_i
18531812
18541813 $ selection_plan = $ presentation ->getSelectionPlan ();
18551814
1856- if (!is_null ($ selection_plan ) && $ selection_plan ->isPrivate () && !$ selection_plan ->containsMember ($ speaker ->getEmail ())){
1815+ if (!is_null ($ selection_plan ) && $ selection_plan ->isPrivate () && !$ selection_plan ->containsMember ($ speaker ->getEmail ())) {
18571816 $ selection_plan ->addAllowedMember ($ speaker ->getEmail ());
18581817 }
18591818
@@ -3246,11 +3205,11 @@ public function processEventData(int $summit_id, string $filename, bool $send_sp
32463205 'email ' => $ speaker_email
32473206 ];
32483207
3249- if (!empty ($ speaker_first_name ) && $ speaker_first_name != $ speaker_email ){
3208+ if (!empty ($ speaker_first_name ) && $ speaker_first_name != $ speaker_email ) {
32503209 $ payload ['first_name ' ] = $ speaker_first_name ;
32513210 }
32523211
3253- if (!empty ($ speaker_last_name ) && $ speaker_last_name != $ speaker_email ){
3212+ if (!empty ($ speaker_last_name ) && $ speaker_last_name != $ speaker_email ) {
32543213 $ payload ['last_name ' ] = $ speaker_last_name ;
32553214 }
32563215
@@ -3821,7 +3780,7 @@ public function deleteEventFeedback(Summit $summit, int $event_id, int $feedback
38213780 * @return string
38223781 * @throws ValidationException
38233782 */
3824- public function generateQREncKey (Summit $ summit ):string
3783+ public function generateQREncKey (Summit $ summit ): string
38253784 {
38263785 Log::debug (sprintf ("SummitService::generateQREncKey summit %s " , $ summit ->getId ()));
38273786 $ res = $ this ->tx_service ->transaction (function () use ($ summit ) {
@@ -3850,24 +3809,24 @@ public function generateQREncKey(Summit $summit):string
38503809 * @return void
38513810 * @throws Exception
38523811 */
3853- public function regenerateBadgeQRCodes (int $ summit_id ):void
3812+ public function regenerateBadgeQRCodes (int $ summit_id ): void
38543813 {
38553814 Log::debug (sprintf ("SummitService::regenerateBadgeQRCodes summit %s " , $ summit_id ));
38563815
3857- $ page = 1 ;
3858- $ count = 0 ;
3816+ $ page = 1 ;
3817+ $ count = 0 ;
38593818
3860- do {
3819+ do {
38613820 Log::debug (sprintf ("SummitService::regenerateBadgeQRCodes summit %s processing page %s " , $ summit_id , $ page ));
38623821 $ page_response = $ this ->summit_attendee_badge_repository ->getBadgeIdsBySummit ($ summit_id , new PagingInfo ($ page , 500 ));
3863- $ has_more = count ($ page_response ->getItems ()) > 0 ;
3822+ $ has_more = count ($ page_response ->getItems ()) > 0 ;
38643823
3865- if (!$ has_more ) {
3824+ if (!$ has_more ) {
38663825 Log::debug (sprintf ("SummitService::regenerateBadgeQRCodes summit %s no more pages " , $ summit_id ));
38673826 continue ;
38683827 }
38693828
3870- foreach ($ page_response ->getItems () as $ page_response_item ){
3829+ foreach ($ page_response ->getItems () as $ page_response_item ) {
38713830
38723831 $ attendee_badge_id = $ page_response_item ['id ' ];
38733832 $ count ++;
@@ -3877,14 +3836,13 @@ public function regenerateBadgeQRCodes(int $summit_id):void
38773836 $ this ->tx_service ->transaction (function () use ($ attendee_badge_id ) {
38783837 try {
38793838 $ attendee_badge = $ this ->summit_attendee_badge_repository ->getById (intval ($ attendee_badge_id ));
3880- if (!$ attendee_badge instanceof SummitAttendeeBadge){
3839+ if (!$ attendee_badge instanceof SummitAttendeeBadge) {
38813840 Log::warning (sprintf ("SummitService::regenerateBadgeQRCodes badge %s not found " , $ attendee_badge_id ));
38823841 return ;
38833842 }
38843843 $ attendee_badge ->generateQRCode ();
3885- }
3886- catch (Exception $ ex ){
3887- Log::error ($ ex );
3844+ } catch (Exception $ ex ) {
3845+ Log::error ($ ex );
38883846 }
38893847 });
38903848 }
@@ -3902,7 +3860,7 @@ public function regenerateBadgeQRCodes(int $summit_id):void
39023860 */
39033861 public function generateMUXPrivateKey (int $ summit_id ): void
39043862 {
3905- $ this ->tx_service ->transaction (function () use ($ summit_id ){
3863+ $ this ->tx_service ->transaction (function () use ($ summit_id ) {
39063864 try {
39073865 Log::debug (sprintf ("SummitService::generateMUXPrivateKey summit %s " , $ summit_id ));
39083866
@@ -3922,8 +3880,7 @@ public function generateMUXPrivateKey(int $summit_id): void
39223880 $ summit ->setMUXPrivateKey ($ key ['private_key ' ]);
39233881
39243882 $ summit ->setMuxPrivateKeyId ($ key ['id ' ]);
3925- }
3926- catch (Exception $ ex ){
3883+ } catch (Exception $ ex ) {
39273884 Log::error ($ ex );
39283885 throw $ ex ;
39293886 }
@@ -3937,7 +3894,7 @@ public function generateMUXPrivateKey(int $summit_id): void
39373894 */
39383895 public function generateMuxPlaybackRestriction (int $ summit_id ): void
39393896 {
3940- $ this ->tx_service ->transaction (function () use ($ summit_id ) {
3897+ $ this ->tx_service ->transaction (function () use ($ summit_id ) {
39413898 try {
39423899 Log::debug (sprintf ("SummitService::generateMuxPlaybackRestriction summit %s " , $ summit_id ));
39433900 $ summit = $ this ->summit_repository ->getById ($ summit_id );
@@ -3991,8 +3948,9 @@ public function generateMuxPlaybackRestriction(int $summit_id): void
39913948 * @return SummitRegistrationFeedMetadata
39923949 * @throws Exception
39933950 */
3994- public function addRegistrationFeedMetadata (Summit $ summit , array $ payload ):SummitRegistrationFeedMetadata {
3995- return $ this ->tx_service ->transaction (function () use ($ summit , $ payload ){
3951+ public function addRegistrationFeedMetadata (Summit $ summit , array $ payload ): SummitRegistrationFeedMetadata
3952+ {
3953+ return $ this ->tx_service ->transaction (function () use ($ summit , $ payload ) {
39963954 return $ summit ->addRegistrationFeedMetadata ($ payload ['key ' ], $ payload ['value ' ]);
39973955 });
39983956 }
@@ -4003,32 +3961,33 @@ public function addRegistrationFeedMetadata(Summit $summit, array $payload):Summ
40033961 * @return void
40043962 * @throws Exception
40053963 */
4006- public function removeRegistrationFeedMetadata (Summit $ summit , int $ metadata_id ):void {
4007- $ this ->tx_service ->transaction (function () use ($ summit , $ metadata_id ){
3964+ public function removeRegistrationFeedMetadata (Summit $ summit , int $ metadata_id ): void
3965+ {
3966+ $ this ->tx_service ->transaction (function () use ($ summit , $ metadata_id ) {
40083967 $ metadata = $ summit ->getRegistrationFeedMetadataById ($ metadata_id );
4009- if (is_null ($ metadata ))
3968+ if (is_null ($ metadata ))
40103969 throw new EntityNotFoundException (sprintf ("Metadata %s not found, " , $ metadata_id ));
40113970 $ summit ->removeRegistrationFeedMetadata ($ metadata );
40123971 });
40133972 }
40143973
40153974 public function updateRegistrationFeedMetadata (Summit $ summit , int $ metadata_id , array $ payload ): SummitRegistrationFeedMetadata
40163975 {
4017- return $ this ->tx_service ->transaction (function () use ($ summit , $ metadata_id , $ payload ){
3976+ return $ this ->tx_service ->transaction (function () use ($ summit , $ metadata_id , $ payload ) {
40183977 $ metadata = $ summit ->getRegistrationFeedMetadataById ($ metadata_id );
4019- if (is_null ($ metadata ))
3978+ if (is_null ($ metadata ))
40203979 throw new EntityNotFoundException (sprintf ("Metadata %s not found, " , $ metadata_id ));
40213980
4022- if (isset ($ payload ['key ' ])) {
3981+ if (isset ($ payload ['key ' ])) {
40233982 $ formerMetadata = $ summit ->getRegistrationFeedMetadataByKey ($ payload ['key ' ]);
4024- if (!is_null ($ formerMetadata ) && $ formerMetadata ->getId () != $ metadata ->getId ())
3983+ if (!is_null ($ formerMetadata ) && $ formerMetadata ->getId () != $ metadata ->getId ())
40253984 throw new ValidationException (sprintf ("Metadata with key %s already exists " , $ payload ['key ' ]));
40263985 }
40273986
40283987
4029- if (isset ($ payload ['value ' ]))
3988+ if (isset ($ payload ['value ' ]))
40303989 $ metadata ->setValue ($ payload ['value ' ]);
4031- if (isset ($ payload ['key ' ]))
3990+ if (isset ($ payload ['key ' ]))
40323991 $ metadata ->setKey ($ payload ['key ' ]);
40333992
40343993 return $ metadata ;
@@ -4079,4 +4038,38 @@ public function updateLeadReportSettings(Summit $summit, array $payload): Summit
40794038 return $ lead_report_settings ;
40804039 });
40814040 }
4041+
4042+ /**
4043+ * @param Summit $summit
4044+ * @param int $event_id
4045+ * @param int $type_id
4046+ * @return SummitEvent
4047+ * @throws Exception
4048+ */
4049+ public function upgradeSummitEvent (Summit $ summit , int $ event_id , int $ type_id ): SummitEvent
4050+ {
4051+ // check first if there is an upgrade or not
4052+
4053+ return $ this ->tx_service ->transaction (function () use ($ summit , $ event_id , $ type_id ) {
4054+
4055+ $ event_type = $ summit ->getEventType ($ type_id );
4056+ if (is_null ($ event_type )) {
4057+ throw new EntityNotFoundException (sprintf ("Event type id %s does not exists. " , $ type_id ));
4058+ }
4059+
4060+ $ event = $ this ->event_repository ->getByIdRefreshed ($ event_id );
4061+ if (is_null ($ event ))
4062+ throw new ValidationException (sprintf ("Event id %s does not exists, " , $ event_id ));
4063+
4064+ $ old_event_type = $ event ->getType ();
4065+
4066+ if ($ old_event_type ->getClassName () != $ event_type ->getClassName () && $ event_type instanceof PresentationType) {
4067+ Log::debug (sprintf ("SummitService::upgradeSummitEvent promoting event %s 2 presentation ... " , $ event_id ));
4068+ $ event ->promote2Presentation ($ event_type );
4069+ return $ event ;
4070+ }
4071+
4072+ throw new ValidationException ("Event type is the same or not a presentation type. " );
4073+ });
4074+ }
40824075}
0 commit comments