PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.14
3.1.14 3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 All 123 releases
firebox / Inc / Core / Analytics / Transformers / TransformerRegistry.php

TransformerRegistry.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 3.1.14, at Inc/Core/Analytics/Transformers/TransformerRegistry.php

107 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 3.1.14 Free
5 *
6 * @author FirePlugins <[email protected]>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Analytics\Transformers;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class TransformerRegistry
20 {
21 /**
22 * @var TransformerInterface[]
23 */
24 private static $transformers = [];
25
26 /**
27 * @var bool
28 */
29 private static $initialized = false;
30
31 /**
32 * Register a transformer
33 *
34 * @param TransformerInterface $transformer
35 */
36 public static function register(TransformerInterface $transformer)
37 {
38 self::$transformers[] = $transformer;
39
40 // Sort by priority (lower numbers first)
41 usort(self::$transformers, function($a, $b) {
42 return $a->getPriority() <=> $b->getPriority();
43 });
44 }
45
46 /**
47 * Get applicable transformers for a type
48 *
49 * @param string $type
50 * @param array $options
51 * @return TransformerInterface[]
52 */
53 public static function getApplicableTransformers($type, $options = [])
54 {
55 self::initializeDefault();
56
57 return array_filter(self::$transformers, function($transformer) use ($type, $options) {
58 return $transformer->shouldApply($type, $options);
59 });
60 }
61
62 /**
63 * Apply all applicable transformers to data
64 *
65 * @param array $data
66 * @param string $type
67 * @param array $options
68 */
69 public static function transformData(&$data, $type, $options = [])
70 {
71 $transformers = self::getApplicableTransformers($type, $options);
72
73 foreach ($transformers as $transformer) {
74 $transformer->transform($data, $type, $options);
75 }
76 }
77
78 /**
79 * Initialize default transformers
80 */
81 private static function initializeDefault()
82 {
83 if (self::$initialized) {
84 return;
85 }
86
87 // Register core transformers
88 self::register(new TimezoneTransformer());
89 self::register(new CountryTransformer());
90 self::register(new DeviceTransformer());
91 self::register(new EventTransformer());
92 self::register(new UrlTransformer());
93 self::register(new CampaignTransformer());
94
95 self::$initialized = true;
96 }
97
98 /**
99 * Reset registry (mainly for testing)
100 */
101 public static function reset()
102 {
103 self::$transformers = [];
104 self::$initialized = false;
105 }
106 }
107