PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.9
Yatra – Travel Booking & Tour Operator Software v3.0.2.9
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 2.0.10 All 83 releases
yatra / app / Providers / ShortcodeServiceProvider.php

ShortcodeServiceProvider.php in Yatra – Travel Booking & Tour Operator Software 3.0.2.9, at app/Providers/ShortcodeServiceProvider.php

108 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Yatra\Providers;
6
7 use Yatra\Shortcodes\MyAccountShortcode;
8 use Yatra\Shortcodes\TripShortcode;
9 use Yatra\Shortcodes\ActivityShortcode;
10 use Yatra\Shortcodes\DestinationShortcode;
11 use Yatra\Shortcodes\DiscountAndDealsShortcode;
12 use Yatra\Shortcodes\SearchShortcode;
13 use Yatra\Shortcodes\LoginShortcode;
14 use Yatra\Ajax\TripShortcodeAjax;
15 use Yatra\Ajax\ActivityShortcodeAjax;
16 use Yatra\Ajax\DestinationShortcodeAjax;
17 use Yatra\Ajax\DiscountShortcodeAjax;
18 use Yatra\Ajax\LoginAjax;
19 use Yatra\Ajax\GeocodingAjax;
20
21 /**
22 * Shortcode Service Provider
23 *
24 * Registers all Yatra shortcodes
25 */
26 class ShortcodeServiceProvider extends \Yatra\Core\ServiceProvider
27 {
28 /**
29 * Register services with production optimizations
30 */
31 public function register(): void
32 {
33 // Register all shortcodes immediately, not on init hook
34 $this->registerShortcodes();
35
36 // Register AJAX handlers with error handling
37 $this->registerAjaxHandlers();
38 }
39
40 /**
41 * Register AJAX handlers with error handling and lazy loading
42 */
43 private function registerAjaxHandlers(): void
44 {
45 $ajax_handlers = [
46 'TripShortcodeAjax',
47 'ActivityShortcodeAjax',
48 'DestinationShortcodeAjax',
49 'DiscountShortcodeAjax',
50 'LoginAjax',
51 'GeocodingAjax',
52 'DirectAttributeQuery',
53 ];
54
55 foreach ($ajax_handlers as $handler_class) {
56 try {
57 $full_class_name = "\\Yatra\\Ajax\\{$handler_class}";
58
59 if (class_exists($full_class_name)) {
60 new $full_class_name();
61 } else {
62
63 }
64 } catch (Exception $e) {
65
66 }
67 }
68 }
69
70 /**
71 * Register all shortcodes with production optimizations
72 */
73 public function registerShortcodes(): void
74 {
75 $shortcodes = [
76 'yatra_my_account' => MyAccountShortcode::class,
77 'yatra_trip' => TripShortcode::class,
78 'yatra_activity' => ActivityShortcode::class,
79 'yatra_destination' => DestinationShortcode::class,
80 'yatra_discount_and_deals' => DiscountAndDealsShortcode::class,
81 'yatra_search' => SearchShortcode::class,
82 'yatra_login' => LoginShortcode::class,
83 ];
84
85 foreach ($shortcodes as $tag => $class) {
86 try {
87 if (class_exists($class)) {
88 $shortcode = new $class();
89
90 // Validate that the shortcode class has the register method
91 if (method_exists($shortcode, 'register')) {
92 $shortcode->register();
93 } else {
94
95 }
96 } else {
97
98 }
99 } catch (\Exception $e) {
100 // Log error for debugging
101
102 // Continue with other shortcodes even if one fails
103 continue;
104 }
105 }
106 }
107 }
108