From f6a42b8d8c8242a57f5d81ea9ece638dc86b1d10 Mon Sep 17 00:00:00 2001 From: Sebastian Marcet Date: Thu, 14 Dec 2017 16:27:29 -0300 Subject: [PATCH] Fixed presentation update process was failing event type update and speakers set Change-Id: I9cd3715d1c4ebed9729ed886218e06d3466b8007 --- .../PresentationSerializer.php | 26 +++++++++---------- app/Services/Model/SummitService.php | 14 +++++++++- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/app/ModelSerializers/PresentationSerializer.php b/app/ModelSerializers/PresentationSerializer.php index 60422b9e..55e42130 100644 --- a/app/ModelSerializers/PresentationSerializer.php +++ b/app/ModelSerializers/PresentationSerializer.php @@ -12,40 +12,40 @@ * limitations under the License. **/ use models\summit\Presentation; - /** * Class PresentationSerializer * @package ModelSerializers */ class PresentationSerializer extends SummitEventSerializer { - protected static $array_mappings = array - ( + protected static $array_mappings = [ + 'Level' => 'level', 'ModeratorId' => 'moderator_speaker_id:json_int', 'ProblemAddressed' => 'problem_addressed:json_string', 'AttendeesExpectedLearnt' => 'attendees_expected_learnt:json_string', 'ToRecord' => 'to_record:json_boolean', 'FeatureCloud' => 'feature_cloud:json_boolean', - ); + ]; + + protected static $allowed_fields = [ - protected static $allowed_fields = array - ( 'track_id', 'moderator_speaker_id', 'level', 'problem_addressed', 'attendees_expected_learnt', - 'to_record' - ); + 'to_record', + 'feature_cloud', + ]; + + protected static $allowed_relations = [ - protected static $allowed_relations = array - ( 'slides', 'videos', 'speakers', 'links', - ); + ]; /** * @param null $expand @@ -92,7 +92,7 @@ class PresentationSerializer extends SummitEventSerializer if(in_array('videos', $relations)) { - $videos = array(); + $videos = []; foreach ($presentation->getVideos() as $video) { $video_values = SerializerRegistry::getInstance()->getSerializer($video)->serialize(); if(empty($video_values['youtube_id'])) continue; @@ -105,7 +105,7 @@ class PresentationSerializer extends SummitEventSerializer foreach (explode(',', $expand) as $relation) { switch (trim($relation)) { case 'speakers': { - $speakers = array(); + $speakers = []; foreach ($presentation->getSpeakers() as $s) { $speakers[] = SerializerRegistry::getInstance()->getSerializer($s)->serialize(); } diff --git a/app/Services/Model/SummitService.php b/app/Services/Model/SummitService.php index d28a5bb1..3de040b1 100644 --- a/app/Services/Model/SummitService.php +++ b/app/Services/Model/SummitService.php @@ -612,7 +612,19 @@ final class SummitService implements ISummitService $event = $this->event_repository->getById($event_id); if (is_null($event)) throw new ValidationException(sprintf("event id %s does not exists!", $event_id)); - $event_type = $event->getType(); + $old_event_type = $event->getType(); + if($event_type != null && $old_event_type->getClassName() != $event_type->getClassName()){ + throw new ValidationException + ( + sprintf + ( + "invalid event type transition for event id %s ( from %s to %s)", + $event_id, + $old_event_type->getClassName(), + $event_type->getClassName() + ) + ); + } } // main data