PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.8
VikBooking Hotel Booking Engine & PMS v1.6.8
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / admin / helpers / src / factory.php

factory.php in VikBooking Hotel Booking Engine & PMS 1.6.8, at admin/helpers/src/factory.php

168 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 JPluginHelper::importPlugin('vikbooking');
15
16 /**
17 * Factory application class.
18 *
19 * @since 1.5
20 */
21 final class VBOFactory
22 {
23 /**
24 * Application configuration handler.
25 *
26 * @var VBOConfigRegistry
27 */
28 private static $config;
29
30 /**
31 * Application platform handler.
32 *
33 * @var VBOPlatformInterface
34 */
35 private static $platform;
36
37 /**
38 * Cron jobs factory instance.
39 *
40 * @var VBOCronFactory
41 */
42 private static $cronFactory;
43
44 /**
45 * Notification Center handler instance.
46 *
47 * @var VBONotificationCenter
48 */
49 private static $notificationCenter;
50
51 /**
52 * Class constructor.
53 * @private This object cannot be instantiated.
54 */
55 private function __construct()
56 {
57 // never called
58 }
59
60 /**
61 * Class cloner.
62 * @private This object cannot be cloned.
63 */
64 private function __clone()
65 {
66 // never called
67 }
68
69 /**
70 * Returns the current configuration object.
71 *
72 * @return VBOConfigRegistry
73 */
74 public static function getConfig()
75 {
76 // check if config class is already instantiated
77 if (is_null(static::$config))
78 {
79 // cache instantiation
80 static::$config = new VBOConfigRegistryDatabase([
81 'db' => JFactory::getDbo(),
82 ]);
83 }
84
85 return static::$config;
86 }
87
88 /**
89 * Returns the current platform handler.
90 *
91 * @return VBOPlatformInterface
92 */
93 public static function getPlatform()
94 {
95 // check if platform class is already instantiated
96 if (is_null(static::$platform))
97 {
98 if (VBOPlatformDetection::isWordPress())
99 {
100 // running WordPress platform
101 static::$platform = new VBOPlatformOrgWordpress();
102 }
103 else
104 {
105 // running Joomla platform
106 static::$platform = new VBOPlatformOrgJoomla();
107 }
108 }
109
110 return static::$platform;
111 }
112
113 /**
114 * Returns the current cron factory.
115 *
116 * @return VBOCronFactory
117 *
118 * @since 1.5.10
119 */
120 public static function getCronFactory()
121 {
122 // check if cron factory class is already instantiated
123 if (is_null(static::$cronFactory))
124 {
125 // create cron factory class and register the default folder
126 static::$cronFactory = new VBOCronFactory;
127 static::$cronFactory->setIncludePaths(VBO_ADMIN_PATH . DIRECTORY_SEPARATOR . 'cronjobs');
128
129 /**
130 * Trigger hook to allow third-party plugin to register custom folders in which
131 * VikBooking should look for the creation of new cron job instances.
132 *
133 * In example:
134 * $factory->addIncludePath($path);
135 * $factory->addIncludePaths([$path1, $path2, ...]);
136 *
137 * @param VBOCronFactory $factory The cron jobs factory.
138 *
139 * @return void
140 *
141 * @since 1.5.10
142 */
143 VBOFactory::getPlatform()->getDispatcher()->trigger('onCreateCronJobsFactoryVikBooking', [static::$cronFactory]);
144 }
145
146 return static::$cronFactory;
147 }
148
149 /**
150 * Returns the current cron notification center instance.
151 *
152 * @return VBONotificationCenter
153 *
154 * @since 1.6.8
155 */
156 public static function getNotificationCenter()
157 {
158 // check if the notification center class is already instantiated
159 if (is_null(static::$notificationCenter))
160 {
161 // create Notification Center class
162 static::$notificationCenter = new VBONotificationCenter;
163 }
164
165 return static::$notificationCenter;
166 }
167 }
168