PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
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 2.0.11 All 82 releases
yatra / app / Providers / ShortcodeServiceProvider.php

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

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