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 +19 -21 3.0.2.7 → 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
@@ -117,8 +118,9 @@
117 118 $data['icon']['value'] = (int) $value;
118 119 }
119 120 }
120 121
122 + $data['icon'] = yatra_normalize_icon_picker_for_storage($data['icon']);
121 123 $data['icon'] = maybe_serialize($data['icon']);
122 124 } elseif (is_string($data['icon'])) {
123 125 // If it's already a string, sanitize it
124 126 $data['icon'] = sanitize_text_field($data['icon']);
@@ -129,15 +131,14 @@
129 131 $data['type'] = 'destination';
130 132
131 133 // Handle SEO metadata
132 134 if (isset($data['seo_title']) || isset($data['seo_description']) || isset($data['seo_keywords'])) {
133 - $existing_metadata = [];
134 - if (isset($data['metadata']) && is_array($data['metadata'])) {
135 - $existing_metadata = $data['metadata'];
136 - } elseif (isset($data['metadata'])) {
137 - $existing_metadata = maybe_unserialize($data['metadata']);
138 - }
139 -
135 + $existing_metadata = ClassificationLandingPageMetadata::baseMetadataMergedWithRequest(
136 + null,
137 + $this->repository,
138 + $data
139 + );
140 +
140 141 // Add SEO fields to metadata
141 142 if (isset($data['seo_title'])) {
142 143 $existing_metadata['seo_title'] = sanitize_text_field($data['seo_title']);
143 144 unset($data['seo_title']); // Remove from main data
@@ -153,8 +154,10 @@
153 154
154 155 $data['metadata'] = $existing_metadata;
155 156 }
156 157
158 + ClassificationLandingPageMetadata::mergeLandingPageIntoData($data, null, $this->repository);
159 +
157 160 return $data;
158 161 }
159 162
160 163 /**
@@ -220,8 +223,9 @@
220 223 $data['icon']['value'] = (int) $value;
221 224 }
222 225 }
223 226
227 + $data['icon'] = yatra_normalize_icon_picker_for_storage($data['icon']);
224 228 $data['icon'] = maybe_serialize($data['icon']);
225 229 } elseif (is_string($data['icon'])) {
226 230 // If it's already a string, sanitize it
227 231 $data['icon'] = sanitize_text_field($data['icon']);
@@ -232,22 +236,14 @@
232 236 $data['type'] = 'destination';
233 237
234 238 // Handle SEO metadata
235 239 if (isset($data['seo_title']) || isset($data['seo_description']) || isset($data['seo_keywords'])) {
236 - // Get existing metadata
237 - $existing_metadata = [];
238 - if (isset($data['metadata']) && is_array($data['metadata'])) {
239 - $existing_metadata = $data['metadata'];
240 - } elseif (isset($data['metadata'])) {
241 - $existing_metadata = maybe_unserialize($data['metadata']);
242 - } else {
243 - // Get existing metadata from database
244 - $existing = $this->repository->find($id);
245 - if ($existing && isset($existing->metadata)) {
246 - $existing_metadata = maybe_unserialize($existing->metadata);
247 - }
248 - }
249 -
240 + $existing_metadata = ClassificationLandingPageMetadata::baseMetadataMergedWithRequest(
241 + $id,
242 + $this->repository,
243 + $data
244 + );
245 +
250 246 // Add/update SEO fields in metadata
251 247 if (isset($data['seo_title'])) {
252 248 $existing_metadata['seo_title'] = sanitize_text_field($data['seo_title']);
253 249 unset($data['seo_title']); // Remove from main data
@@ -262,8 +258,10 @@
262 258 }
263 259
264 260 $data['metadata'] = $existing_metadata;
265 261 }
262 +
263 + ClassificationLandingPageMetadata::mergeLandingPageIntoData($data, $id, $this->repository);
266 264
267 265 return $data;
268 266 }
269 267