Skip to content

Commit f4fd1bd

Browse files
Refactor code
1 parent 6fddb10 commit f4fd1bd

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

lib/internal/Magento/Framework/Interception/PluginList/PluginList.php

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -292,28 +292,7 @@ protected function _loadScopedData()
292292
$this->_loadedScopes[$scopeCode] = true;
293293
}
294294
} else {
295-
$virtualTypes = [];
296-
foreach ($this->_scopePriorityScheme as $scopeCode) {
297-
if (false == isset($this->_loadedScopes[$scopeCode])) {
298-
$data = $this->_reader->read($scopeCode) ?: [];
299-
unset($data['preferences']);
300-
if (count($data) > 0) {
301-
$this->_inherited = [];
302-
$this->_processed = [];
303-
$this->merge($data);
304-
foreach ($data as $class => $config) {
305-
if (isset($config['type'])) {
306-
$virtualTypes[] = $class;
307-
}
308-
}
309-
}
310-
$this->_loadedScopes[$scopeCode] = true;
311-
}
312-
if ($this->isCurrentScope($scopeCode)) {
313-
break;
314-
}
315-
}
316-
foreach ($virtualTypes as $class) {
295+
foreach ($this->_loadScopedVirtualTypes() as $class) {
317296
$this->_inheritPlugins($class);
318297
}
319298
foreach ($this->getClassDefinitions() as $class) {
@@ -328,6 +307,37 @@ protected function _loadScopedData()
328307
}
329308
}
330309

310+
/**
311+
* Load virtual types for current scope
312+
*
313+
* @return array
314+
*/
315+
private function _loadScopedVirtualTypes()
316+
{
317+
$virtualTypes = [];
318+
foreach ($this->_scopePriorityScheme as $scopeCode) {
319+
if (!isset($this->_loadedScopes[$scopeCode])) {
320+
$data = $this->_reader->read($scopeCode) ?: [];
321+
unset($data['preferences']);
322+
if (count($data) > 0) {
323+
$this->_inherited = [];
324+
$this->_processed = [];
325+
$this->merge($data);
326+
foreach ($data as $class => $config) {
327+
if (isset($config['type'])) {
328+
$virtualTypes[] = $class;
329+
}
330+
}
331+
}
332+
$this->_loadedScopes[$scopeCode] = true;
333+
}
334+
if ($this->isCurrentScope($scopeCode)) {
335+
break;
336+
}
337+
}
338+
return $virtualTypes;
339+
}
340+
331341
/**
332342
* Whether scope code is current scope code
333343
*

0 commit comments

Comments
 (0)