PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | vendor/jetpack-autoloader/class-container.php +150 -0 16.2-beta → 16.3 View file →
@@ -1,0 +1,150 @@
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\jpf11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ16_3\al6_0_1;
9 +
10 + // phpcs:ignore
11 +
12 +/**
13 + * This class manages the files and dependencies of the autoloader.
14 + */
15 +class Container {
16 +
17 + /**
18 + * Since each autoloader's class files exist within their own namespace we need a map to
19 + * convert between the local class and a shared key. Note that no version checking is
20 + * performed on these dependencies and the first autoloader to register will be the
21 + * one that is utilized.
22 + */
23 + const SHARED_DEPENDENCY_KEYS = array(
24 + Hook_Manager::class => 'Hook_Manager',
25 + );
26 +
27 + /**
28 + * A map of all the dependencies we've registered with the container and created.
29 + *
30 + * @var array
31 + */
32 + protected $dependencies;
33 +
34 + /**
35 + * The constructor.
36 + */
37 + public function __construct() {
38 + $this->dependencies = array();
39 +
40 + $this->register_shared_dependencies();
41 + $this->register_dependencies();
42 + $this->initialize_globals();
43 + }
44 +
45 + /**
46 + * Gets a dependency out of the container.
47 + *
48 + * @param string $class The class to fetch.
49 + *
50 + * @return mixed
51 + * @throws \InvalidArgumentException When a class that isn't registered with the container is fetched.
52 + */
53 + public function get( $class ) {
54 + if ( ! isset( $this->dependencies[ $class ] ) ) {
55 + throw new \InvalidArgumentException( "Class '$class' is not registered with the container." );
56 + }
57 +
58 + return $this->dependencies[ $class ];
59 + }
60 +
61 + /**
62 + * Registers all of the dependencies that are shared between all instances of the autoloader.
63 + */
64 + private function register_shared_dependencies() {
65 + global $jetpack_autoloader_container_shared;
66 + if ( ! isset( $jetpack_autoloader_container_shared ) ) {
67 + $jetpack_autoloader_container_shared = array();
68 + }
69 +
70 + $key = self::SHARED_DEPENDENCY_KEYS[ Hook_Manager::class ];
71 + if ( ! isset( $jetpack_autoloader_container_shared[ $key ] ) ) {
72 + require_once __DIR__ . '/class-hook-manager.php';
73 + $jetpack_autoloader_container_shared[ $key ] = new Hook_Manager();
74 + }
75 + $this->dependencies[ Hook_Manager::class ] = &$jetpack_autoloader_container_shared[ $key ];
76 + }
77 +
78 + /**
79 + * Registers all of the dependencies with the container.
80 + */
81 + private function register_dependencies() {
82 + require_once __DIR__ . '/class-path-processor.php';
83 + $this->dependencies[ Path_Processor::class ] = new Path_Processor();
84 +
85 + require_once __DIR__ . '/class-plugin-locator.php';
86 + $this->dependencies[ Plugin_Locator::class ] = new Plugin_Locator(
87 + $this->get( Path_Processor::class )
88 + );
89 +
90 + require_once __DIR__ . '/class-version-selector.php';
91 + $this->dependencies[ Version_Selector::class ] = new Version_Selector();
92 +
93 + require_once __DIR__ . '/class-autoloader-locator.php';
94 + $this->dependencies[ Autoloader_Locator::class ] = new Autoloader_Locator(
95 + $this->get( Version_Selector::class )
96 + );
97 +
98 + require_once __DIR__ . '/class-php-autoloader.php';
99 + $this->dependencies[ PHP_Autoloader::class ] = new PHP_Autoloader();
100 +
101 + require_once __DIR__ . '/class-manifest-reader.php';
102 + $this->dependencies[ Manifest_Reader::class ] = new Manifest_Reader(
103 + $this->get( Version_Selector::class )
104 + );
105 +
106 + require_once __DIR__ . '/class-plugins-handler.php';
107 + $this->dependencies[ Plugins_Handler::class ] = new Plugins_Handler(
108 + $this->get( Plugin_Locator::class ),
109 + $this->get( Path_Processor::class )
110 + );
111 +
112 + require_once __DIR__ . '/class-autoloader-handler.php';
113 + $this->dependencies[ Autoloader_Handler::class ] = new Autoloader_Handler(
114 + $this->get( PHP_Autoloader::class ),
115 + $this->get( Hook_Manager::class ),
116 + $this->get( Manifest_Reader::class ),
117 + $this->get( Version_Selector::class )
118 + );
119 +
120 + require_once __DIR__ . '/class-latest-autoloader-guard.php';
121 + $this->dependencies[ Latest_Autoloader_Guard::class ] = new Latest_Autoloader_Guard(
122 + $this->get( Plugins_Handler::class ),
123 + $this->get( Autoloader_Handler::class ),
124 + $this->get( Autoloader_Locator::class )
125 + );
126 +
127 + // Register any classes that we will use elsewhere.
128 + require_once __DIR__ . '/class-version-loader.php';
129 + require_once __DIR__ . '/class-shutdown-handler.php';
130 + }
131 +
132 + /**
133 + * Initializes any of the globals needed by the autoloader.
134 + */
135 + private function initialize_globals() {
136 + /*
137 + * This global was retired in version 2.9. The value is set to 'false' to maintain
138 + * compatibility with older versions of the autoloader.
139 + */
140 + global $jetpack_autoloader_including_latest;
141 + $jetpack_autoloader_including_latest = false;
142 +
143 + // Not all plugins can be found using the locator. In cases where a plugin loads the autoloader
144 + // but was not discoverable, we will record them in this array to track them as "active".
145 + global $jetpack_autoloader_activating_plugins_paths;
146 + if ( ! isset( $jetpack_autoloader_activating_plugins_paths ) ) {
147 + $jetpack_autoloader_activating_plugins_paths = array();
148 + }
149 + }
150 +}