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/ActivityService.php +21 -33 3.0.2.6 → 3.0.16 View file →
@@ -4,8 +4,9 @@
4 4
5 5 namespace Yatra\Services;
6 6
7 7 use Yatra\Repositories\ActivityRepository;
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
@@ -71,9 +72,9 @@
71 72 // Always auto-generate slug from name (backend ensures uniqueness)
72 73 if (!empty($data['name'])) {
73 74 $data['slug'] = SlugHelper::generateUniqueFromDatabase(
74 75 $data['name'],
75 - 'yatra_new_classifications',
76 + 'yatra_classifications',
76 77 'slug'
77 78 );
78 79 } elseif (isset($data['slug'])) {
79 80 // If name is empty but slug is provided, sanitize it
@@ -120,8 +121,9 @@
120 121 $data['icon']['value'] = (int) $value;
121 122 }
122 123 }
123 124
125 + $data['icon'] = yatra_normalize_icon_picker_for_storage($data['icon']);
124 126 $data['icon'] = maybe_serialize($data['icon']);
125 127 } elseif (is_string($data['icon'])) {
126 128 // If it's already a string, sanitize it
127 129 $data['icon'] = sanitize_text_field($data['icon']);
@@ -129,16 +131,14 @@
129 131 }
130 132
131 133 // Handle SEO metadata
132 134 if (isset($data['seo_title']) || isset($data['seo_description']) || isset($data['seo_keywords'])) {
133 -
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 /**
@@ -220,18 +222,10 @@
220 222 $data['icon']['value'] = (int) $value;
221 223 }
222 224 }
223 225
224 - // Sanitize icon array
225 - $icon = [
226 - 'type' => isset($data['icon']['type']) && in_array($data['icon']['type'], ['icon', 'image'], true)
227 - ? $data['icon']['type']
228 - : 'icon',
229 - 'value' => isset($data['icon']['value'])
230 - ? sanitize_text_field($data['icon']['value'])
231 - : '',
232 - ];
233 - $data['icon'] = maybe_serialize($icon);
226 + $data['icon'] = yatra_normalize_icon_picker_for_storage($data['icon']);
227 + $data['icon'] = maybe_serialize($data['icon']);
234 228 } elseif (is_string($data['icon'])) {
235 229 // If it's already a string, sanitize it
236 230 $data['icon'] = sanitize_text_field($data['icon']);
237 231 }
@@ -238,22 +232,14 @@
238 232 }
239 233
240 234 // Handle SEO metadata
241 235 if (isset($data['seo_title']) || isset($data['seo_description']) || isset($data['seo_keywords'])) {
242 - // Get existing metadata
243 - $existing_metadata = [];
244 - if (isset($data['metadata']) && is_array($data['metadata'])) {
245 - $existing_metadata = $data['metadata'];
246 - } elseif (isset($data['metadata'])) {
247 - $existing_metadata = maybe_unserialize($data['metadata']);
248 - } else {
249 - // Get existing metadata from database
250 - $existing = $this->repository->find($id);
251 - if ($existing && isset($existing->metadata)) {
252 - $existing_metadata = maybe_unserialize($existing->metadata);
253 - }
254 - }
255 -
236 + $existing_metadata = ClassificationLandingPageMetadata::baseMetadataMergedWithRequest(
237 + $id,
238 + $this->repository,
239 + $data
240 + );
241 +
256 242 // Add/update SEO fields in metadata
257 243 if (isset($data['seo_title'])) {
258 244 $existing_metadata['seo_title'] = sanitize_text_field($data['seo_title']);
259 245 unset($data['seo_title']); // Remove from main data
@@ -268,8 +254,10 @@
268 254 }
269 255
270 256 $data['metadata'] = $existing_metadata;
271 257 }
258 +
259 + ClassificationLandingPageMetadata::mergeLandingPageIntoData($data, $id, $this->repository);
272 260
273 261 return $data;
274 262 }
275 263