PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | app/Services/DestinationService.php +16 -25 3.0.3 → 3.0.16 View file →
@@ -4,8 +4,9 @@
4 4
5 5 namespace Yatra\Services;
6 6
7 7 use Yatra\Repositories\DestinationRepository;
8 +use Yatra\Helpers\ClassificationLandingPageMetadata;
8 9 use Yatra\Helpers\SlugHelper;
9 10 use Yatra\Helpers\FormatHelper;
10 11 use Yatra\Database\Tables\ClassificationsTable;
11 12
@@ -130,15 +131,14 @@
130 131 $data['type'] = 'destination';
131 132
132 133 // Handle SEO metadata
133 134 if (isset($data['seo_title']) || isset($data['seo_description']) || isset($data['seo_keywords'])) {
134 - $existing_metadata = [];
135 - if (isset($data['metadata']) && is_array($data['metadata'])) {
136 - $existing_metadata = $data['metadata'];
137 - } elseif (isset($data['metadata'])) {
138 - $existing_metadata = maybe_unserialize($data['metadata']);
139 - }
140 -
135 + $existing_metadata = ClassificationLandingPageMetadata::baseMetadataMergedWithRequest(
136 + null,
137 + $this->repository,
138 + $data
139 + );
140 +
141 141 // Add SEO fields to metadata
142 142 if (isset($data['seo_title'])) {
143 143 $existing_metadata['seo_title'] = sanitize_text_field($data['seo_title']);
144 144 unset($data['seo_title']); // Remove from main data
@@ -154,8 +154,10 @@
154 154
155 155 $data['metadata'] = $existing_metadata;
156 156 }
157 157
158 + ClassificationLandingPageMetadata::mergeLandingPageIntoData($data, null, $this->repository);
159 +
158 160 return $data;
159 161 }
160 162
161 163 /**
@@ -234,27 +236,14 @@
234 236 $data['type'] = 'destination';
235 237
236 238 // Handle SEO metadata
237 239 if (isset($data['seo_title']) || isset($data['seo_description']) || isset($data['seo_keywords'])) {
238 - // Get existing metadata
239 - $existing_metadata = [];
240 - if (isset($data['metadata']) && is_array($data['metadata'])) {
241 - $existing_metadata = $data['metadata'];
242 - } elseif (isset($data['metadata'])) {
243 - $existing_metadata = maybe_unserialize($data['metadata']);
244 - } else {
245 - // Get existing metadata from database
246 - $existing = $this->repository->find($id);
247 - if ($existing && isset($existing->metadata)) {
248 - $existing_metadata = maybe_unserialize($existing->metadata);
249 - }
250 - }
240 + $existing_metadata = ClassificationLandingPageMetadata::baseMetadataMergedWithRequest(
241 + $id,
242 + $this->repository,
243 + $data
244 + );
251 245
252 - // `metadata` can be stored as serialized string or other scalar; ensure array before offset access.
253 - if (!is_array($existing_metadata)) {
254 - $existing_metadata = [];
255 - }
256 -
257 246 // Add/update SEO fields in metadata
258 247 if (isset($data['seo_title'])) {
259 248 $existing_metadata['seo_title'] = sanitize_text_field($data['seo_title']);
260 249 unset($data['seo_title']); // Remove from main data
@@ -269,8 +258,10 @@
269 258 }
270 259
271 260 $data['metadata'] = $existing_metadata;
272 261 }
262 +
263 + ClassificationLandingPageMetadata::mergeLandingPageIntoData($data, $id, $this->repository);
273 264
274 265 return $data;
275 266 }
276 267