PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / vendor / jetpack-autoloader / class-autoloader-handler.php

class-autoloader-handler.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at vendor/jetpack-autoloader/class-autoloader-handler.php

148 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This file was automatically generated by automattic/jetpack-autoloader.
4 *
5 * @package automattic/jetpack-autoloader
6 */
7
8 namespace Automattic\Jetpack\Autoloader\jp9596fa42a27a19b46fd381ad6137fd57\al5_0_23;
9
10 // phpcs:ignore
11
12 use Automattic\Jetpack\Autoloader\AutoloadGenerator;
13
14 /**
15 * This class selects the package version for the autoloader.
16 */
17 class Autoloader_Handler {
18
19 /**
20 * The PHP_Autoloader instance.
21 *
22 * @var PHP_Autoloader
23 */
24 private $php_autoloader;
25
26 /**
27 * The Hook_Manager instance.
28 *
29 * @var Hook_Manager
30 */
31 private $hook_manager;
32
33 /**
34 * The Manifest_Reader instance.
35 *
36 * @var Manifest_Reader
37 */
38 private $manifest_reader;
39
40 /**
41 * The Version_Selector instance.
42 *
43 * @var Version_Selector
44 */
45 private $version_selector;
46
47 /**
48 * The constructor.
49 *
50 * @param PHP_Autoloader $php_autoloader The PHP_Autoloader instance.
51 * @param Hook_Manager $hook_manager The Hook_Manager instance.
52 * @param Manifest_Reader $manifest_reader The Manifest_Reader instance.
53 * @param Version_Selector $version_selector The Version_Selector instance.
54 */
55 public function __construct( $php_autoloader, $hook_manager, $manifest_reader, $version_selector ) {
56 $this->php_autoloader = $php_autoloader;
57 $this->hook_manager = $hook_manager;
58 $this->manifest_reader = $manifest_reader;
59 $this->version_selector = $version_selector;
60 }
61
62 /**
63 * Checks to see whether or not an autoloader is currently in the process of initializing.
64 *
65 * @return bool
66 */
67 public function is_initializing() {
68 // If no version has been set it means that no autoloader has started initializing yet.
69 global $jetpack_autoloader_latest_version;
70 if ( ! isset( $jetpack_autoloader_latest_version ) ) {
71 return false;
72 }
73
74 // When the version is set but the classmap is not it ALWAYS means that this is the
75 // latest autoloader and is being included by an older one.
76 global $jetpack_packages_classmap;
77 if ( empty( $jetpack_packages_classmap ) ) {
78 return true;
79 }
80
81 // Version 2.4.0 added a new global and altered the reset semantics. We need to check
82 // the other global as well since it may also point at initialization.
83 // Note: We don't need to check for the class first because every autoloader that
84 // will set the latest version global requires this class in the classmap.
85 $replacing_version = $jetpack_packages_classmap[ AutoloadGenerator::class ]['version'];
86 if ( $this->version_selector->is_dev_version( $replacing_version ) || version_compare( $replacing_version, '2.4.0.0', '>=' ) ) {
87 global $jetpack_autoloader_loader;
88 if ( ! isset( $jetpack_autoloader_loader ) ) {
89 return true;
90 }
91 }
92
93 return false;
94 }
95
96 /**
97 * Activates an autoloader using the given plugins and activates it.
98 *
99 * @param string[] $plugins The plugins to initialize the autoloader for.
100 */
101 public function activate_autoloader( $plugins ) {
102 global $jetpack_packages_psr4;
103 $jetpack_packages_psr4 = array();
104 $this->manifest_reader->read_manifests( $plugins, 'vendor/composer/jetpack_autoload_psr4.php', $jetpack_packages_psr4 );
105
106 global $jetpack_packages_classmap;
107 $jetpack_packages_classmap = array();
108 $this->manifest_reader->read_manifests( $plugins, 'vendor/composer/jetpack_autoload_classmap.php', $jetpack_packages_classmap );
109
110 global $jetpack_packages_filemap;
111 $jetpack_packages_filemap = array();
112 $this->manifest_reader->read_manifests( $plugins, 'vendor/composer/jetpack_autoload_filemap.php', $jetpack_packages_filemap );
113
114 $loader = new Version_Loader(
115 $this->version_selector,
116 $jetpack_packages_classmap,
117 $jetpack_packages_psr4,
118 $jetpack_packages_filemap
119 );
120
121 $this->php_autoloader->register_autoloader( $loader );
122
123 // Now that the autoloader is active we can load the filemap.
124 $loader->load_filemap();
125 }
126
127 /**
128 * Resets the active autoloader and all related global state.
129 */
130 public function reset_autoloader() {
131 $this->php_autoloader->unregister_autoloader();
132 $this->hook_manager->reset();
133
134 // Clear all of the autoloader globals so that older autoloaders don't do anything strange.
135 global $jetpack_autoloader_latest_version;
136 $jetpack_autoloader_latest_version = null;
137
138 global $jetpack_packages_classmap;
139 $jetpack_packages_classmap = array(); // Must be array to avoid exceptions in old autoloaders!
140
141 global $jetpack_packages_psr4;
142 $jetpack_packages_psr4 = array(); // Must be array to avoid exceptions in old autoloaders!
143
144 global $jetpack_packages_filemap;
145 $jetpack_packages_filemap = array(); // Must be array to avoid exceptions in old autoloaders!
146 }
147 }
148