Completed
Pull Request — Gutenberg/master (#614)
by
unknown
14:30
created
core/services/route_match/RouteMatchSpecificationManager.php 2 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -25,122 +25,122 @@
 block discarded – undo
25 25
  */
26 26
 class RouteMatchSpecificationManager
27 27
 {
28
-    /**
29
-     * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications
30
-     */
31
-    private $specifications;
28
+	/**
29
+	 * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications
30
+	 */
31
+	private $specifications;
32 32
 
33
-    /**
34
-     * @var RouteMatchSpecificationFactory $specifications_factory
35
-     */
36
-    private $specifications_factory;
33
+	/**
34
+	 * @var RouteMatchSpecificationFactory $specifications_factory
35
+	 */
36
+	private $specifications_factory;
37 37
 
38 38
 
39
-    /**
40
-     * RouteMatchSpecificationManager constructor.
41
-     *
42
-     * @param RouteMatchSpecificationCollection $specifications
43
-     * @param RouteMatchSpecificationFactory    $specifications_factory
44
-     */
45
-    public function __construct(
46
-        RouteMatchSpecificationCollection $specifications,
47
-        RouteMatchSpecificationFactory $specifications_factory
48
-    ) {
49
-        $this->specifications = $specifications;
50
-        $this->specifications_factory = $specifications_factory;
51
-        add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize'));
52
-    }
39
+	/**
40
+	 * RouteMatchSpecificationManager constructor.
41
+	 *
42
+	 * @param RouteMatchSpecificationCollection $specifications
43
+	 * @param RouteMatchSpecificationFactory    $specifications_factory
44
+	 */
45
+	public function __construct(
46
+		RouteMatchSpecificationCollection $specifications,
47
+		RouteMatchSpecificationFactory $specifications_factory
48
+	) {
49
+		$this->specifications = $specifications;
50
+		$this->specifications_factory = $specifications_factory;
51
+		add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize'));
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Perform any early setup required for block editors to functions
57
-     *
58
-     * @return void
59
-     * @throws CollectionLoaderException
60
-     * @throws CollectionDetailsException
61
-     */
62
-    public function initialize()
63
-    {
64
-        $this->populateSpecificationCollection();
65
-    }
55
+	/**
56
+	 * Perform any early setup required for block editors to functions
57
+	 *
58
+	 * @return void
59
+	 * @throws CollectionLoaderException
60
+	 * @throws CollectionDetailsException
61
+	 */
62
+	public function initialize()
63
+	{
64
+		$this->populateSpecificationCollection();
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * @return CollectionInterface|RouteMatchSpecificationInterface[]
70
-     * @throws CollectionLoaderException
71
-     * @throws CollectionDetailsException
72
-     * @since $VID:$
73
-     */
74
-    private function populateSpecificationCollection()
75
-    {
76
-        $loader = new CollectionLoader(
77
-            new CollectionDetails(
78
-                // collection name
79
-                RouteMatchSpecificationCollection::COLLECTION_NAME,
80
-                // collection interface
81
-                'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface',
82
-                // FQCNs for classes to add (all classes within each namespace will be loaded)
83
-                apply_filters(
84
-                    'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs',
85
-                    array(
86
-                        'EventEspresso\core\domain\entities\route_match\specifications\admin',
87
-                        // 'EventEspresso\core\domain\entities\route_match\specifications\public',
88
-                    )
89
-                ),
90
-                // filepaths to classes to add
91
-                array(),
92
-                // file mask to use if parsing folder for files to add
93
-                '',
94
-                // what to use as identifier for collection entities
95
-                // using CLASS NAME prevents duplicates (works like a singleton)
96
-                CollectionDetails::ID_CLASS_NAME
97
-            ),
98
-            $this->specifications,
99
-            null,
100
-            $this->specifications_factory
101
-        );
102
-        return $loader->getCollection();
103
-    }
68
+	/**
69
+	 * @return CollectionInterface|RouteMatchSpecificationInterface[]
70
+	 * @throws CollectionLoaderException
71
+	 * @throws CollectionDetailsException
72
+	 * @since $VID:$
73
+	 */
74
+	private function populateSpecificationCollection()
75
+	{
76
+		$loader = new CollectionLoader(
77
+			new CollectionDetails(
78
+				// collection name
79
+				RouteMatchSpecificationCollection::COLLECTION_NAME,
80
+				// collection interface
81
+				'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface',
82
+				// FQCNs for classes to add (all classes within each namespace will be loaded)
83
+				apply_filters(
84
+					'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs',
85
+					array(
86
+						'EventEspresso\core\domain\entities\route_match\specifications\admin',
87
+						// 'EventEspresso\core\domain\entities\route_match\specifications\public',
88
+					)
89
+				),
90
+				// filepaths to classes to add
91
+				array(),
92
+				// file mask to use if parsing folder for files to add
93
+				'',
94
+				// what to use as identifier for collection entities
95
+				// using CLASS NAME prevents duplicates (works like a singleton)
96
+				CollectionDetails::ID_CLASS_NAME
97
+			),
98
+			$this->specifications,
99
+			null,
100
+			$this->specifications_factory
101
+		);
102
+		return $loader->getCollection();
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches
108
-     *
109
-     * @param string $routeMatchSpecificationFqcn fully qualified class name
110
-     * @return bool
111
-     * @throws InvalidClassException
112
-     * @since $VID:$
113
-     */
114
-    public function routeMatchesCurrentRequest($routeMatchSpecificationFqcn)
115
-    {
116
-        /** @var RouteMatchSpecificationInterface $specification */
117
-        $specification = $this->specifications->get($routeMatchSpecificationFqcn);
118
-        if (! $specification instanceof $routeMatchSpecificationFqcn) {
119
-            throw new InvalidClassException($routeMatchSpecificationFqcn);
120
-        }
121
-        return $specification->isMatchingRoute();
122
-    }
106
+	/**
107
+	 * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches
108
+	 *
109
+	 * @param string $routeMatchSpecificationFqcn fully qualified class name
110
+	 * @return bool
111
+	 * @throws InvalidClassException
112
+	 * @since $VID:$
113
+	 */
114
+	public function routeMatchesCurrentRequest($routeMatchSpecificationFqcn)
115
+	{
116
+		/** @var RouteMatchSpecificationInterface $specification */
117
+		$specification = $this->specifications->get($routeMatchSpecificationFqcn);
118
+		if (! $specification instanceof $routeMatchSpecificationFqcn) {
119
+			throw new InvalidClassException($routeMatchSpecificationFqcn);
120
+		}
121
+		return $specification->isMatchingRoute();
122
+	}
123 123
 
124 124
 
125
-    /**
126
-     * Handy method for development that returns
127
-     * a list of existing RouteMatchSpecification classes
128
-     * matching the current request that can be used to identify it.
129
-     * If no matches are returned (or nothing acceptable)
130
-     * then create a new one that better matches your requirements.
131
-     *
132
-     * @return array
133
-     * @since $VID:$
134
-     */
135
-    public function findRouteMatchSpecificationsMatchingCurrentRequest()
136
-    {
137
-        $matches = array();
138
-        foreach ($this->specifications as $specification) {
139
-            /** @var RouteMatchSpecificationInterface $specification */
140
-            if ($specification->isMatchingRoute()) {
141
-                $matches[] = get_class($specification);
142
-            }
143
-        }
144
-        return $matches;
145
-    }
125
+	/**
126
+	 * Handy method for development that returns
127
+	 * a list of existing RouteMatchSpecification classes
128
+	 * matching the current request that can be used to identify it.
129
+	 * If no matches are returned (or nothing acceptable)
130
+	 * then create a new one that better matches your requirements.
131
+	 *
132
+	 * @return array
133
+	 * @since $VID:$
134
+	 */
135
+	public function findRouteMatchSpecificationsMatchingCurrentRequest()
136
+	{
137
+		$matches = array();
138
+		foreach ($this->specifications as $specification) {
139
+			/** @var RouteMatchSpecificationInterface $specification */
140
+			if ($specification->isMatchingRoute()) {
141
+				$matches[] = get_class($specification);
142
+			}
143
+		}
144
+		return $matches;
145
+	}
146 146
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@
 block discarded – undo
115 115
     {
116 116
         /** @var RouteMatchSpecificationInterface $specification */
117 117
         $specification = $this->specifications->get($routeMatchSpecificationFqcn);
118
-        if (! $specification instanceof $routeMatchSpecificationFqcn) {
118
+        if ( ! $specification instanceof $routeMatchSpecificationFqcn) {
119 119
             throw new InvalidClassException($routeMatchSpecificationFqcn);
120 120
         }
121 121
         return $specification->isMatchingRoute();
Please login to merge, or discard this patch.
core/services/editor/BlockRegistrationManager.php 2 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -32,207 +32,207 @@
 block discarded – undo
32 32
 class BlockRegistrationManager extends BlockManager
33 33
 {
34 34
 
35
-    /**
36
-     * @var BlockAssetManagerCollection $block_asset_manager_collection
37
-     */
38
-    protected $block_asset_manager_collection;
39
-
40
-    /**
41
-     * @var RouteMatchSpecificationManager $route_manager
42
-     */
43
-    protected $route_manager;
44
-
45
-    /**
46
-     * array for tracking asset managers required by blocks for the current route
47
-     *
48
-     * @var array $block_asset_managers
49
-     */
50
-    protected $block_asset_managers = array();
51
-
52
-
53
-    /**
54
-     * BlockRegistrationManager constructor.
55
-     *
56
-     * @param BlockAssetManagerCollection    $block_asset_manager_collection
57
-     * @param BlockCollection                $blocks
58
-     * @param RouteMatchSpecificationManager $route_manager
59
-     * @param RequestInterface               $request
60
-     */
61
-    public function __construct(
62
-        BlockAssetManagerCollection $block_asset_manager_collection,
63
-        BlockCollection $blocks,
64
-        RouteMatchSpecificationManager $route_manager,
65
-        RequestInterface $request
66
-    ) {
67
-        $this->block_asset_manager_collection = $block_asset_manager_collection;
68
-        $this->route_manager = $route_manager;
69
-        parent::__construct($blocks, $request);
70
-    }
71
-
72
-
73
-    /**
74
-     *  Returns the name of a hookpoint to be used to call initialize()
75
-     *
76
-     * @return string
77
-     */
78
-    public function initHook()
79
-    {
80
-        return 'AHEE__EE_System__initialize';
81
-    }
82
-
83
-
84
-    /**
85
-     * Perform any early setup required for block editors to functions
86
-     *
87
-     * @return void
88
-     * @throws Exception
89
-     */
90
-    public function initialize()
91
-    {
92
-        $this->initializeBlocks();
93
-        add_action('AHEE__EE_System__initialize_last', array($this, 'registerBlocks'));
94
-        add_action('wp_loaded', array($this, 'unloadAssets'));
95
-    }
96
-
97
-
98
-    /**
99
-     * @return CollectionInterface|BlockInterface[]
100
-     * @throws CollectionLoaderException
101
-     * @throws CollectionDetailsException
102
-     */
103
-    protected function populateBlockCollection()
104
-    {
105
-        $loader = new CollectionLoader(
106
-            new CollectionDetails(
107
-                // collection name
108
-                'editor_blocks',
109
-                // collection interface
110
-                'EventEspresso\core\domain\entities\editor\BlockInterface',
111
-                // FQCNs for classes to add (all classes within each namespace will be loaded)
112
-                apply_filters(
113
-                    'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs',
114
-                    array(
115
-                        // 'EventEspresso\core\domain\entities\editor\blocks\common',
116
-                        // 'EventEspresso\core\domain\entities\editor\blocks\editor',
117
-                        // 'EventEspresso\core\domain\entities\editor\blocks\widgets',
118
-                    )
119
-                ),
120
-                // filepaths to classes to add
121
-                array(),
122
-                // file mask to use if parsing folder for files to add
123
-                '',
124
-                // what to use as identifier for collection entities
125
-                // using CLASS NAME prevents duplicates (works like a singleton)
126
-                CollectionDetails::ID_CLASS_NAME
127
-            ),
128
-            $this->blocks
129
-        );
130
-        return $loader->getCollection();
131
-    }
132
-
133
-
134
-    /**
135
-     * populates the BlockCollection and calls initialize() on all installed blocks
136
-     *
137
-     * @return void
138
-     * @throws Exception
139
-     */
140
-    public function initializeBlocks()
141
-    {
142
-        try {
143
-            $this->populateBlockCollection();
144
-            // cycle thru block loaders and initialize each loader
145
-            foreach ($this->blocks as $block) {
146
-                $block->initialize();
147
-                $this->trackAssetManagersForBlocks($block);
148
-                if (! $this->block_asset_manager_collection->has($block->assetManager())) {
149
-                    $this->block_asset_manager_collection->add($block->assetManager());
150
-                    $block->assetManager()->setAssetHandles();
151
-                }
152
-            }
153
-        } catch (Exception $exception) {
154
-            new ExceptionStackTraceDisplay($exception);
155
-        }
156
-    }
157
-
158
-
159
-    /**
160
-     * track blocks with routes that match the current request
161
-     *
162
-     * @param BlockInterface $block
163
-     * @throws InvalidClassException
164
-     */
165
-    private function trackAssetManagersForBlocks(BlockInterface $block)
166
-    {
167
-        $supported_routes = $block->supportedRoutes();
168
-        foreach ($supported_routes as $supported_route) {
169
-            if ($this->route_manager->routeMatchesCurrentRequest($supported_route)) {
170
-                $this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace();
171
-            }
172
-        }
173
-    }
174
-
175
-
176
-    /**
177
-     * returns true if the block should be registered for the current request
178
-     * else removes block from block_routes array and returns false
179
-     *
180
-     * @param BlockInterface $block
181
-     * @return boolean
182
-     * @throws InvalidClassException
183
-     */
184
-    public function matchesRoute(BlockInterface $block)
185
-    {
186
-        if (isset($this->block_asset_managers[ $block->blockType() ])) {
187
-            return true;
188
-        }
189
-        unset($this->block_asset_managers[ $block->blockType() ]);
190
-        return false;
191
-    }
192
-
193
-
194
-    /**
195
-     * calls registerBlock() and load assets for all installed blocks
196
-     *
197
-     * @return void
198
-     * @throws Exception
199
-     */
200
-    public function registerBlocks()
201
-    {
202
-        try {
203
-            // cycle thru block loader folders
204
-            foreach ($this->blocks as $block) {
205
-                if (! $this->matchesRoute($block)) {
206
-                    continue;
207
-                }
208
-                // perform any setup required for the block
209
-                $block_type = $block->registerBlock();
210
-                if (! $block_type instanceof WP_Block_Type) {
211
-                    throw new InvalidEntityException($block_type, 'WP_Block_Type');
212
-                }
213
-                do_action(
214
-                    'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered',
215
-                    $block,
216
-                    $block_type
217
-                );
218
-            }
219
-        } catch (Exception $exception) {
220
-            new ExceptionStackTraceDisplay($exception);
221
-        }
222
-    }
223
-
224
-    public function unloadAssets()
225
-    {
226
-        $assets = array_flip($this->block_asset_managers);
227
-        foreach ($this->block_asset_manager_collection as $asset_manager) {
228
-            // if there are no longer any blocks that require these assets,
229
-            if (! isset($assets[ $asset_manager->assetNamespace() ])) {
230
-                // then unset asset enqueueing and bail
231
-                remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0);
232
-                remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0);
233
-                remove_action('wp_enqueue_scripts', array($asset_manager, 'addAssets'), 2);
234
-                remove_action('admin_enqueue_scripts', array($asset_manager, 'addAssets'), 2);
235
-            }
236
-        }
237
-    }
35
+	/**
36
+	 * @var BlockAssetManagerCollection $block_asset_manager_collection
37
+	 */
38
+	protected $block_asset_manager_collection;
39
+
40
+	/**
41
+	 * @var RouteMatchSpecificationManager $route_manager
42
+	 */
43
+	protected $route_manager;
44
+
45
+	/**
46
+	 * array for tracking asset managers required by blocks for the current route
47
+	 *
48
+	 * @var array $block_asset_managers
49
+	 */
50
+	protected $block_asset_managers = array();
51
+
52
+
53
+	/**
54
+	 * BlockRegistrationManager constructor.
55
+	 *
56
+	 * @param BlockAssetManagerCollection    $block_asset_manager_collection
57
+	 * @param BlockCollection                $blocks
58
+	 * @param RouteMatchSpecificationManager $route_manager
59
+	 * @param RequestInterface               $request
60
+	 */
61
+	public function __construct(
62
+		BlockAssetManagerCollection $block_asset_manager_collection,
63
+		BlockCollection $blocks,
64
+		RouteMatchSpecificationManager $route_manager,
65
+		RequestInterface $request
66
+	) {
67
+		$this->block_asset_manager_collection = $block_asset_manager_collection;
68
+		$this->route_manager = $route_manager;
69
+		parent::__construct($blocks, $request);
70
+	}
71
+
72
+
73
+	/**
74
+	 *  Returns the name of a hookpoint to be used to call initialize()
75
+	 *
76
+	 * @return string
77
+	 */
78
+	public function initHook()
79
+	{
80
+		return 'AHEE__EE_System__initialize';
81
+	}
82
+
83
+
84
+	/**
85
+	 * Perform any early setup required for block editors to functions
86
+	 *
87
+	 * @return void
88
+	 * @throws Exception
89
+	 */
90
+	public function initialize()
91
+	{
92
+		$this->initializeBlocks();
93
+		add_action('AHEE__EE_System__initialize_last', array($this, 'registerBlocks'));
94
+		add_action('wp_loaded', array($this, 'unloadAssets'));
95
+	}
96
+
97
+
98
+	/**
99
+	 * @return CollectionInterface|BlockInterface[]
100
+	 * @throws CollectionLoaderException
101
+	 * @throws CollectionDetailsException
102
+	 */
103
+	protected function populateBlockCollection()
104
+	{
105
+		$loader = new CollectionLoader(
106
+			new CollectionDetails(
107
+				// collection name
108
+				'editor_blocks',
109
+				// collection interface
110
+				'EventEspresso\core\domain\entities\editor\BlockInterface',
111
+				// FQCNs for classes to add (all classes within each namespace will be loaded)
112
+				apply_filters(
113
+					'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs',
114
+					array(
115
+						// 'EventEspresso\core\domain\entities\editor\blocks\common',
116
+						// 'EventEspresso\core\domain\entities\editor\blocks\editor',
117
+						// 'EventEspresso\core\domain\entities\editor\blocks\widgets',
118
+					)
119
+				),
120
+				// filepaths to classes to add
121
+				array(),
122
+				// file mask to use if parsing folder for files to add
123
+				'',
124
+				// what to use as identifier for collection entities
125
+				// using CLASS NAME prevents duplicates (works like a singleton)
126
+				CollectionDetails::ID_CLASS_NAME
127
+			),
128
+			$this->blocks
129
+		);
130
+		return $loader->getCollection();
131
+	}
132
+
133
+
134
+	/**
135
+	 * populates the BlockCollection and calls initialize() on all installed blocks
136
+	 *
137
+	 * @return void
138
+	 * @throws Exception
139
+	 */
140
+	public function initializeBlocks()
141
+	{
142
+		try {
143
+			$this->populateBlockCollection();
144
+			// cycle thru block loaders and initialize each loader
145
+			foreach ($this->blocks as $block) {
146
+				$block->initialize();
147
+				$this->trackAssetManagersForBlocks($block);
148
+				if (! $this->block_asset_manager_collection->has($block->assetManager())) {
149
+					$this->block_asset_manager_collection->add($block->assetManager());
150
+					$block->assetManager()->setAssetHandles();
151
+				}
152
+			}
153
+		} catch (Exception $exception) {
154
+			new ExceptionStackTraceDisplay($exception);
155
+		}
156
+	}
157
+
158
+
159
+	/**
160
+	 * track blocks with routes that match the current request
161
+	 *
162
+	 * @param BlockInterface $block
163
+	 * @throws InvalidClassException
164
+	 */
165
+	private function trackAssetManagersForBlocks(BlockInterface $block)
166
+	{
167
+		$supported_routes = $block->supportedRoutes();
168
+		foreach ($supported_routes as $supported_route) {
169
+			if ($this->route_manager->routeMatchesCurrentRequest($supported_route)) {
170
+				$this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace();
171
+			}
172
+		}
173
+	}
174
+
175
+
176
+	/**
177
+	 * returns true if the block should be registered for the current request
178
+	 * else removes block from block_routes array and returns false
179
+	 *
180
+	 * @param BlockInterface $block
181
+	 * @return boolean
182
+	 * @throws InvalidClassException
183
+	 */
184
+	public function matchesRoute(BlockInterface $block)
185
+	{
186
+		if (isset($this->block_asset_managers[ $block->blockType() ])) {
187
+			return true;
188
+		}
189
+		unset($this->block_asset_managers[ $block->blockType() ]);
190
+		return false;
191
+	}
192
+
193
+
194
+	/**
195
+	 * calls registerBlock() and load assets for all installed blocks
196
+	 *
197
+	 * @return void
198
+	 * @throws Exception
199
+	 */
200
+	public function registerBlocks()
201
+	{
202
+		try {
203
+			// cycle thru block loader folders
204
+			foreach ($this->blocks as $block) {
205
+				if (! $this->matchesRoute($block)) {
206
+					continue;
207
+				}
208
+				// perform any setup required for the block
209
+				$block_type = $block->registerBlock();
210
+				if (! $block_type instanceof WP_Block_Type) {
211
+					throw new InvalidEntityException($block_type, 'WP_Block_Type');
212
+				}
213
+				do_action(
214
+					'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered',
215
+					$block,
216
+					$block_type
217
+				);
218
+			}
219
+		} catch (Exception $exception) {
220
+			new ExceptionStackTraceDisplay($exception);
221
+		}
222
+	}
223
+
224
+	public function unloadAssets()
225
+	{
226
+		$assets = array_flip($this->block_asset_managers);
227
+		foreach ($this->block_asset_manager_collection as $asset_manager) {
228
+			// if there are no longer any blocks that require these assets,
229
+			if (! isset($assets[ $asset_manager->assetNamespace() ])) {
230
+				// then unset asset enqueueing and bail
231
+				remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0);
232
+				remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0);
233
+				remove_action('wp_enqueue_scripts', array($asset_manager, 'addAssets'), 2);
234
+				remove_action('admin_enqueue_scripts', array($asset_manager, 'addAssets'), 2);
235
+			}
236
+		}
237
+	}
238 238
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
             foreach ($this->blocks as $block) {
146 146
                 $block->initialize();
147 147
                 $this->trackAssetManagersForBlocks($block);
148
-                if (! $this->block_asset_manager_collection->has($block->assetManager())) {
148
+                if ( ! $this->block_asset_manager_collection->has($block->assetManager())) {
149 149
                     $this->block_asset_manager_collection->add($block->assetManager());
150 150
                     $block->assetManager()->setAssetHandles();
151 151
                 }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $supported_routes = $block->supportedRoutes();
168 168
         foreach ($supported_routes as $supported_route) {
169 169
             if ($this->route_manager->routeMatchesCurrentRequest($supported_route)) {
170
-                $this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace();
170
+                $this->block_asset_managers[$block->blockType()] = $block->assetManager()->assetNamespace();
171 171
             }
172 172
         }
173 173
     }
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
      */
184 184
     public function matchesRoute(BlockInterface $block)
185 185
     {
186
-        if (isset($this->block_asset_managers[ $block->blockType() ])) {
186
+        if (isset($this->block_asset_managers[$block->blockType()])) {
187 187
             return true;
188 188
         }
189
-        unset($this->block_asset_managers[ $block->blockType() ]);
189
+        unset($this->block_asset_managers[$block->blockType()]);
190 190
         return false;
191 191
     }
192 192
 
@@ -202,12 +202,12 @@  discard block
 block discarded – undo
202 202
         try {
203 203
             // cycle thru block loader folders
204 204
             foreach ($this->blocks as $block) {
205
-                if (! $this->matchesRoute($block)) {
205
+                if ( ! $this->matchesRoute($block)) {
206 206
                     continue;
207 207
                 }
208 208
                 // perform any setup required for the block
209 209
                 $block_type = $block->registerBlock();
210
-                if (! $block_type instanceof WP_Block_Type) {
210
+                if ( ! $block_type instanceof WP_Block_Type) {
211 211
                     throw new InvalidEntityException($block_type, 'WP_Block_Type');
212 212
                 }
213 213
                 do_action(
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         $assets = array_flip($this->block_asset_managers);
227 227
         foreach ($this->block_asset_manager_collection as $asset_manager) {
228 228
             // if there are no longer any blocks that require these assets,
229
-            if (! isset($assets[ $asset_manager->assetNamespace() ])) {
229
+            if ( ! isset($assets[$asset_manager->assetNamespace()])) {
230 230
                 // then unset asset enqueueing and bail
231 231
                 remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0);
232 232
                 remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0);
Please login to merge, or discard this patch.
entities/route_match/specifications/admin/WordPressPostsEditorEdit.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class WordPressPostsEditorEdit extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since $VID:$
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return strpos($this->request->requestUri(), 'wp-admin/post.php') !== false
26
-            && $this->request->getRequestParam('post_type', 'post') === 'post'
27
-            && $this->request->getRequestParam('action') === 'edit';
28
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since $VID:$
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return strpos($this->request->requestUri(), 'wp-admin/post.php') !== false
26
+			&& $this->request->getRequestParam('post_type', 'post') === 'post'
27
+			&& $this->request->getRequestParam('action') === 'edit';
28
+	}
29 29
 }
Please login to merge, or discard this patch.
entities/route_match/specifications/admin/WordPressPostsEditorAddNew.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class WordPressPostsEditorAddNew extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since $VID:$
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return strpos($this->request->requestUri(), 'wp-admin/post-new.php') !== false
26
-            && $this->request->getRequestParam('post_type', 'post') === 'post';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since $VID:$
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return strpos($this->request->requestUri(), 'wp-admin/post-new.php') !== false
26
+			&& $this->request->getRequestParam('post_type', 'post') === 'post';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
entities/route_match/specifications/admin/WordPressPostsListTable.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class WordPressPostsListTable extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since $VID:$
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return strpos($this->request->requestUri(), 'wp-admin/edit.php') !== false
26
-            && $this->request->getRequestParam('post_type', 'post') === 'post';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since $VID:$
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return strpos($this->request->requestUri(), 'wp-admin/edit.php') !== false
26
+			&& $this->request->getRequestParam('post_type', 'post') === 'post';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/WordPressPostsEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class WordPressPostsEditor extends MatchAnyRouteSpecification
20 20
 {
21
-    /**
22
-     * WordPressPostsEditor constructor.
23
-     *
24
-     * @param WordPressPostsEditorEdit   $edit_event_route_match
25
-     * @param WordPressPostsEditorAddNew $create_event_route_match
26
-     * @param RequestInterface           $request
27
-     * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
-     */
29
-    public function __construct(
30
-        WordPressPostsEditorEdit $edit_event_route_match,
31
-        WordPressPostsEditorAddNew $create_event_route_match,
32
-        RequestInterface $request
33
-    ) {
34
-        parent::__construct(
35
-            array($edit_event_route_match, $create_event_route_match),
36
-            $request
37
-        );
38
-    }
21
+	/**
22
+	 * WordPressPostsEditor constructor.
23
+	 *
24
+	 * @param WordPressPostsEditorEdit   $edit_event_route_match
25
+	 * @param WordPressPostsEditorAddNew $create_event_route_match
26
+	 * @param RequestInterface           $request
27
+	 * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
+	 */
29
+	public function __construct(
30
+		WordPressPostsEditorEdit $edit_event_route_match,
31
+		WordPressPostsEditorAddNew $create_event_route_match,
32
+		RequestInterface $request
33
+	) {
34
+		parent::__construct(
35
+			array($edit_event_route_match, $create_event_route_match),
36
+			$request
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/EspressoEventEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,22 +19,22 @@
 block discarded – undo
19 19
  */
20 20
 class EspressoEventEditor extends MatchAnyRouteSpecification
21 21
 {
22
-    /**
23
-     * AddNewOrEditEventAdminPageRouteMatch constructor.
24
-     *
25
-     * @param EspressoEventEditorEdit   $edit_event_route_match
26
-     * @param EspressoEventEditorAddNew $create_event_route_match
27
-     * @param RequestInterface          $request
28
-     * @throws InvalidEntityException
29
-     */
30
-    public function __construct(
31
-        EspressoEventEditorEdit $edit_event_route_match,
32
-        EspressoEventEditorAddNew $create_event_route_match,
33
-        RequestInterface $request
34
-    ) {
35
-        parent::__construct(
36
-            array($edit_event_route_match, $create_event_route_match),
37
-            $request
38
-        );
39
-    }
22
+	/**
23
+	 * AddNewOrEditEventAdminPageRouteMatch constructor.
24
+	 *
25
+	 * @param EspressoEventEditorEdit   $edit_event_route_match
26
+	 * @param EspressoEventEditorAddNew $create_event_route_match
27
+	 * @param RequestInterface          $request
28
+	 * @throws InvalidEntityException
29
+	 */
30
+	public function __construct(
31
+		EspressoEventEditorEdit $edit_event_route_match,
32
+		EspressoEventEditorAddNew $create_event_route_match,
33
+		RequestInterface $request
34
+	) {
35
+		parent::__construct(
36
+			array($edit_event_route_match, $create_event_route_match),
37
+			$request
38
+		);
39
+	}
40 40
 }
Please login to merge, or discard this patch.
core/services/route_match/RouteMatchSpecificationDependencyResolver.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -22,20 +22,20 @@
 block discarded – undo
22 22
 class RouteMatchSpecificationDependencyResolver extends DependencyResolver
23 23
 {
24 24
 
25
-    /**
26
-     * Used to configure and/or setup any aliases or namespace roots required by the DependencyResolver
27
-     *
28
-     * @since $VID:$
29
-     * @throws InvalidAliasException
30
-     */
31
-    public function initialize()
32
-    {
33
-        $this->addAlias(
34
-            new ClassAlias(
35
-                'EventEspresso\core\services\request\RequestInterface',
36
-                'EventEspresso\core\services\request\Request'
37
-            )
38
-        );
39
-        $this->addNamespaceRoot('EventEspresso\core\domain\entities\route_match\specifications');
40
-    }
25
+	/**
26
+	 * Used to configure and/or setup any aliases or namespace roots required by the DependencyResolver
27
+	 *
28
+	 * @since $VID:$
29
+	 * @throws InvalidAliasException
30
+	 */
31
+	public function initialize()
32
+	{
33
+		$this->addAlias(
34
+			new ClassAlias(
35
+				'EventEspresso\core\services\request\RequestInterface',
36
+				'EventEspresso\core\services\request\Request'
37
+			)
38
+		);
39
+		$this->addNamespaceRoot('EventEspresso\core\domain\entities\route_match\specifications');
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/services/dependencies/DependencyResolver.php 2 patches
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -23,155 +23,155 @@
 block discarded – undo
23 23
 abstract class DependencyResolver implements DependencyResolverInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @var Mirror $mirror
28
-     */
29
-    private $mirror;
30
-
31
-    /**
32
-     * @var ClassInterfaceCache $class_cache
33
-     */
34
-    private $class_cache;
35
-
36
-    /**
37
-     * @var EE_Dependency_Map $dependency_map
38
-     */
39
-    private $dependency_map;
40
-
41
-    /**
42
-     * @var ClassAlias[] $aliases
43
-     */
44
-    protected $aliases = array();
45
-
46
-    /**
47
-     * @var array $namespace_roots
48
-     */
49
-    protected $namespace_roots = array();
50
-
51
-
52
-    /**
53
-     * RouteMatchSpecificationDependencyResolver constructor.
54
-     *
55
-     * @param Mirror              $mirror
56
-     * @param ClassInterfaceCache $class_cache
57
-     * @param EE_Dependency_Map   $dependency_map
58
-     */
59
-    public function __construct(
60
-        Mirror $mirror,
61
-        ClassInterfaceCache $class_cache,
62
-        EE_Dependency_Map $dependency_map
63
-    ) {
64
-        $this->mirror = $mirror;
65
-        $this->class_cache = $class_cache;
66
-        $this->dependency_map = $dependency_map;
67
-        $this->initialize();
68
-    }
69
-
70
-    /**
71
-     * @return Mirror
72
-     */
73
-    public function mirror()
74
-    {
75
-        return $this->mirror;
76
-    }
77
-
78
-    /**
79
-     * @return ClassInterfaceCache
80
-     */
81
-    public function classCache()
82
-    {
83
-        return $this->class_cache;
84
-    }
85
-
86
-    /**
87
-     * @return EE_Dependency_Map
88
-     */
89
-    public function dependencyMap()
90
-    {
91
-        return $this->dependency_map;
92
-    }
93
-
94
-    /**
95
-     * @param ClassAlias $alias
96
-     * @throws InvalidAliasException
97
-     */
98
-    public function addAlias(ClassAlias $alias)
99
-    {
100
-        $this->aliases[ $alias->alias() ] = $alias;
101
-    }
102
-
103
-    /**
104
-     * @param string $param_fqcn Fully Qualified Class Name for dependency parameter
105
-     * @return string
106
-     */
107
-    public function resolveAlias($param_fqcn)
108
-    {
109
-        return isset($this->aliases[ $param_fqcn ])
110
-            ? $this->aliases[ $param_fqcn ]->fqcn()
111
-            : $this->classCache()->getFqnForAlias($param_fqcn);
112
-    }
113
-
114
-    /**
115
-     * Primarily used to indicate the namespace root for composite objects
116
-     * so that dependencies requiring the same DependencyResolver can be acquired
117
-     * for example:
118
-     * Vendor\path\to\class\A, Vendor\path\to\class\B, and Vendor\path\to\class\C
119
-     * may all implement Vendor\path\to\Interface,
120
-     * but Vendor\path\to\class\C could be a composite object
121
-     * that requires Vendor\path\to\class\A and Vendor\path\to\class\B,
122
-     * and needs both of those dependencies resolved, which would therefore require
123
-     * the use of the same DependencyResolver.
124
-     *
125
-     * By specifying a namespace root of "Vendor\path\to\",
126
-     * then all classes that are descendants of that namespace
127
-     * will use DependencyResolver to acquire the classes they need
128
-     *
129
-     * @param string $namespace_root Partial namespace used for detecting other classes
130
-     *                               that should employ this same DependencyResolver
131
-     */
132
-    public function addNamespaceRoot($namespace_root)
133
-    {
134
-        $this->namespace_roots[] = $namespace_root;
135
-    }
136
-
137
-    /**
138
-     * Returns true if the parameter FQCN belongs to one of
139
-     * the namespaces that utilizes this DependencyResolver
140
-     *
141
-     * @param string $param_fqcn Fully Qualified Class Name for dependency parameter
142
-     * @return boolean
143
-     * @since $VID:$
144
-     */
145
-    public function dependencyRecursionExists($param_fqcn)
146
-    {
147
-        foreach ($this->namespace_roots as $namespace_root) {
148
-            if (strpos($param_fqcn, $namespace_root) !== false) {
149
-                return true;
150
-            }
151
-        }
152
-        return false;
153
-    }
154
-
155
-
156
-    /**
157
-     * @param string $fqcn Fully Qualified Class Name
158
-     * @throws InvalidDataTypeException
159
-     * @throws ReflectionException
160
-     * @since $VID:$
161
-     */
162
-    public function resolveDependenciesForClass($fqcn)
163
-    {
164
-        $dependencies = array();
165
-        $params = $this->mirror()->getParameters($fqcn);
166
-        foreach ($params as $index => $param) {
167
-            // is this a dependency for a specific class ?
168
-            $param_class = $this->mirror()->getParameterClassName($param, $fqcn, $index);
169
-            if ($this->dependencyRecursionExists($param_class)) {
170
-                $this->resolveDependenciesForClass($param_class);
171
-            }
172
-            $param_class = $this->resolveAlias($param_class);
173
-            $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache;
174
-        }
175
-        $this->dependencyMap()->registerDependencies($fqcn, $dependencies);
176
-    }
26
+	/**
27
+	 * @var Mirror $mirror
28
+	 */
29
+	private $mirror;
30
+
31
+	/**
32
+	 * @var ClassInterfaceCache $class_cache
33
+	 */
34
+	private $class_cache;
35
+
36
+	/**
37
+	 * @var EE_Dependency_Map $dependency_map
38
+	 */
39
+	private $dependency_map;
40
+
41
+	/**
42
+	 * @var ClassAlias[] $aliases
43
+	 */
44
+	protected $aliases = array();
45
+
46
+	/**
47
+	 * @var array $namespace_roots
48
+	 */
49
+	protected $namespace_roots = array();
50
+
51
+
52
+	/**
53
+	 * RouteMatchSpecificationDependencyResolver constructor.
54
+	 *
55
+	 * @param Mirror              $mirror
56
+	 * @param ClassInterfaceCache $class_cache
57
+	 * @param EE_Dependency_Map   $dependency_map
58
+	 */
59
+	public function __construct(
60
+		Mirror $mirror,
61
+		ClassInterfaceCache $class_cache,
62
+		EE_Dependency_Map $dependency_map
63
+	) {
64
+		$this->mirror = $mirror;
65
+		$this->class_cache = $class_cache;
66
+		$this->dependency_map = $dependency_map;
67
+		$this->initialize();
68
+	}
69
+
70
+	/**
71
+	 * @return Mirror
72
+	 */
73
+	public function mirror()
74
+	{
75
+		return $this->mirror;
76
+	}
77
+
78
+	/**
79
+	 * @return ClassInterfaceCache
80
+	 */
81
+	public function classCache()
82
+	{
83
+		return $this->class_cache;
84
+	}
85
+
86
+	/**
87
+	 * @return EE_Dependency_Map
88
+	 */
89
+	public function dependencyMap()
90
+	{
91
+		return $this->dependency_map;
92
+	}
93
+
94
+	/**
95
+	 * @param ClassAlias $alias
96
+	 * @throws InvalidAliasException
97
+	 */
98
+	public function addAlias(ClassAlias $alias)
99
+	{
100
+		$this->aliases[ $alias->alias() ] = $alias;
101
+	}
102
+
103
+	/**
104
+	 * @param string $param_fqcn Fully Qualified Class Name for dependency parameter
105
+	 * @return string
106
+	 */
107
+	public function resolveAlias($param_fqcn)
108
+	{
109
+		return isset($this->aliases[ $param_fqcn ])
110
+			? $this->aliases[ $param_fqcn ]->fqcn()
111
+			: $this->classCache()->getFqnForAlias($param_fqcn);
112
+	}
113
+
114
+	/**
115
+	 * Primarily used to indicate the namespace root for composite objects
116
+	 * so that dependencies requiring the same DependencyResolver can be acquired
117
+	 * for example:
118
+	 * Vendor\path\to\class\A, Vendor\path\to\class\B, and Vendor\path\to\class\C
119
+	 * may all implement Vendor\path\to\Interface,
120
+	 * but Vendor\path\to\class\C could be a composite object
121
+	 * that requires Vendor\path\to\class\A and Vendor\path\to\class\B,
122
+	 * and needs both of those dependencies resolved, which would therefore require
123
+	 * the use of the same DependencyResolver.
124
+	 *
125
+	 * By specifying a namespace root of "Vendor\path\to\",
126
+	 * then all classes that are descendants of that namespace
127
+	 * will use DependencyResolver to acquire the classes they need
128
+	 *
129
+	 * @param string $namespace_root Partial namespace used for detecting other classes
130
+	 *                               that should employ this same DependencyResolver
131
+	 */
132
+	public function addNamespaceRoot($namespace_root)
133
+	{
134
+		$this->namespace_roots[] = $namespace_root;
135
+	}
136
+
137
+	/**
138
+	 * Returns true if the parameter FQCN belongs to one of
139
+	 * the namespaces that utilizes this DependencyResolver
140
+	 *
141
+	 * @param string $param_fqcn Fully Qualified Class Name for dependency parameter
142
+	 * @return boolean
143
+	 * @since $VID:$
144
+	 */
145
+	public function dependencyRecursionExists($param_fqcn)
146
+	{
147
+		foreach ($this->namespace_roots as $namespace_root) {
148
+			if (strpos($param_fqcn, $namespace_root) !== false) {
149
+				return true;
150
+			}
151
+		}
152
+		return false;
153
+	}
154
+
155
+
156
+	/**
157
+	 * @param string $fqcn Fully Qualified Class Name
158
+	 * @throws InvalidDataTypeException
159
+	 * @throws ReflectionException
160
+	 * @since $VID:$
161
+	 */
162
+	public function resolveDependenciesForClass($fqcn)
163
+	{
164
+		$dependencies = array();
165
+		$params = $this->mirror()->getParameters($fqcn);
166
+		foreach ($params as $index => $param) {
167
+			// is this a dependency for a specific class ?
168
+			$param_class = $this->mirror()->getParameterClassName($param, $fqcn, $index);
169
+			if ($this->dependencyRecursionExists($param_class)) {
170
+				$this->resolveDependenciesForClass($param_class);
171
+			}
172
+			$param_class = $this->resolveAlias($param_class);
173
+			$dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache;
174
+		}
175
+		$this->dependencyMap()->registerDependencies($fqcn, $dependencies);
176
+	}
177 177
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function addAlias(ClassAlias $alias)
99 99
     {
100
-        $this->aliases[ $alias->alias() ] = $alias;
100
+        $this->aliases[$alias->alias()] = $alias;
101 101
     }
102 102
 
103 103
     /**
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function resolveAlias($param_fqcn)
108 108
     {
109
-        return isset($this->aliases[ $param_fqcn ])
110
-            ? $this->aliases[ $param_fqcn ]->fqcn()
109
+        return isset($this->aliases[$param_fqcn])
110
+            ? $this->aliases[$param_fqcn]->fqcn()
111 111
             : $this->classCache()->getFqnForAlias($param_fqcn);
112 112
     }
113 113
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                 $this->resolveDependenciesForClass($param_class);
171 171
             }
172 172
             $param_class = $this->resolveAlias($param_class);
173
-            $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache;
173
+            $dependencies[$param_class] = EE_Dependency_Map::load_from_cache;
174 174
         }
175 175
         $this->dependencyMap()->registerDependencies($fqcn, $dependencies);
176 176
     }
Please login to merge, or discard this patch.