1 | <?php |
||
7 | class Autoloader_Handler { |
||
8 | |||
9 | // The name of the autoloader function registered by v1.* autoloaders. |
||
10 | const V1_AUTOLOADER_NAME = 'Automattic\Jetpack\Autoloader\autoloader'; |
||
11 | |||
12 | /* |
||
13 | * The autoloader function for v2.* autoloaders is named __NAMESPACE__ . \autoloader. |
||
14 | * The namespace is defined in AutoloadGenerator as |
||
15 | * 'Automattic\Jetpack\Autoloader\jp' plus a unique suffix. |
||
16 | */ |
||
17 | const V2_AUTOLOADER_BASE = 'Automattic\Jetpack\Autoloader\jp'; |
||
18 | |||
19 | /** |
||
20 | * The current plugin path. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | private $current_plugin_path; |
||
25 | |||
26 | /** |
||
27 | * The paths for all of the active plugins. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | private $active_plugin_paths; |
||
32 | |||
33 | /** |
||
34 | * The Autoloader_Locator object. |
||
35 | * |
||
36 | * @var Autoloader_Locator |
||
37 | */ |
||
38 | private $autoloader_locator; |
||
39 | |||
40 | /** |
||
41 | * The Version_Selector object. |
||
42 | * |
||
43 | * @var Version_Selector |
||
44 | */ |
||
45 | private $version_selector; |
||
46 | |||
47 | /** |
||
48 | * The constructor. |
||
49 | * |
||
50 | * @param string $current_plugin_path The current plugin path. |
||
51 | * @param array $active_plugin_paths The active plugin paths. |
||
52 | * @param Autoloader_Locator $autoloader_locator The Autoloader_Locator object. |
||
53 | * @param Version_Selector $version_selector The Version_Selector object. |
||
54 | */ |
||
55 | public function __construct( $current_plugin_path, $active_plugin_paths, $autoloader_locator, $version_selector ) { |
||
61 | |||
62 | /** |
||
63 | * Finds the latest installed autoloader. |
||
64 | * |
||
65 | * @return bool True if this autoloader is the latest, false otherwise. |
||
66 | */ |
||
67 | public function is_latest_autoloader() { |
||
86 | |||
87 | /** |
||
88 | * Checks whether the autoloader should be reset. The autoloader should be reset |
||
89 | * when a plugin is activating via a method other than a request, for example |
||
90 | * using WP-CLI. When this occurs, the activating plugin was not known when |
||
91 | * the autoloader selected the package versions for the classmap and filemap |
||
92 | * globals, so the autoloader must reselect the versions. |
||
93 | * |
||
94 | * If the current plugin is not already known, this method will add it to the |
||
95 | * $jetpack_autoloader_activating_plugins_paths global. |
||
96 | * |
||
97 | * @return boolean True if the autoloder must be reset, else false. |
||
98 | */ |
||
99 | public function should_autoloader_reset() { |
||
114 | |||
115 | /** |
||
116 | * Builds the Version_Autoloader class that is used for autoloading. |
||
117 | * |
||
118 | * @return Version_Loader |
||
119 | */ |
||
120 | public function build_autoloader() { |
||
143 | |||
144 | /** |
||
145 | * Updates the spl autoloader chain: |
||
146 | * - Registers this namespace's autoloader function. |
||
147 | * - If a v1 autoloader function is registered, moves it to the end of the chain. |
||
148 | * - Removes any other v2 autoloader functions that have already been registered. This |
||
149 | * can occur when the autoloader is being reset by an activating plugin. |
||
150 | */ |
||
151 | public function update_autoloader_chain() { |
||
179 | } |
||
180 |