From 973129d4e8d9017b794465a59bc1abab99db493d Mon Sep 17 00:00:00 2001 From: Jens Schulze Date: Thu, 10 Mar 2016 17:34:51 +0100 Subject: [PATCH] fix(Review): fix locale serialization for review models --- src/Model/Review/Review.php | 9 +++++++++ src/Model/Review/ReviewDraft.php | 9 +++++++++ src/Request/Reviews/Command/ReviewSetLocaleAction.php | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/src/Model/Review/Review.php b/src/Model/Review/Review.php index d8ab65cdba..82c06dd73a 100644 --- a/src/Model/Review/Review.php +++ b/src/Model/Review/Review.php @@ -83,4 +83,13 @@ public function fieldDefinitions() 'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObject'], ]; } + + public function jsonSerialize() + { + $data = parent::jsonSerialize(); + if (isset($data['locale'])) { + $data['locale'] = str_replace('_', '-', $data['locale']); + } + return $data; + } } diff --git a/src/Model/Review/ReviewDraft.php b/src/Model/Review/ReviewDraft.php index ff1bd8c5bb..a1a4069c89 100644 --- a/src/Model/Review/ReviewDraft.php +++ b/src/Model/Review/ReviewDraft.php @@ -86,4 +86,13 @@ public static function ofRating($rating, $context = null) { return static::of($context)->setRating($rating); } + + public function jsonSerialize() + { + $data = parent::jsonSerialize(); + if (isset($data['locale'])) { + $data['locale'] = str_replace('_', '-', $data['locale']); + } + return $data; + } } diff --git a/src/Request/Reviews/Command/ReviewSetLocaleAction.php b/src/Request/Reviews/Command/ReviewSetLocaleAction.php index dcafd27ee8..a021f49a21 100644 --- a/src/Request/Reviews/Command/ReviewSetLocaleAction.php +++ b/src/Request/Reviews/Command/ReviewSetLocaleAction.php @@ -35,4 +35,13 @@ public function __construct(array $data = [], $context = null) parent::__construct($data, $context); $this->setAction('setLocale'); } + + public function jsonSerialize() + { + $data = parent::jsonSerialize(); + if (isset($data['locale'])) { + $data['locale'] = str_replace('_', '-', $data['locale']); + } + return $data; + } }