diff --git a/Model/Config/Reader/Dom.php b/Model/Config/Reader/Dom.php index f8a99a0..5cf50f1 100644 --- a/Model/Config/Reader/Dom.php +++ b/Model/Config/Reader/Dom.php @@ -26,13 +26,14 @@ public function getClassRewriteConflicts() $type = $preference->getAttribute('type'); if ($for && $type) { if (!isset($conflicts[$for])) { - $conflicts[$for] = [ - 'classes' => [] - ]; + $conflicts[$for] = []; } - if (!in_array($type, $conflicts[$for]['classes'])) { - $conflicts[$for]['classes'][] = $type; + if (!isset($conflicts[$for][$scope])) { + $conflicts[$for][$scope] = []; + } + if (!in_array($type, $conflicts[$for][$scope])) { + $conflicts[$for][$scope][] = $type; } } } @@ -41,23 +42,45 @@ public function getClassRewriteConflicts() } } - foreach ($conflicts as $origClass => $item) { - $hasNoMagentoClasses = false; - foreach ($item['classes'] as $class) { - if (strpos($class, 'Magento\\') !== 0 && strpos($class, '\\Magento\\') !== 0) { - $hasNoMagentoClasses = true; + foreach ($conflicts as $for => $scopeClasses) { + foreach ($scopeClasses as $scope => $classes) { + $hasNoMagentoClasses = false; + foreach ($classes as $class) { + if (strpos($class, 'Magento\\') !== 0 && strpos($class, '\\Magento\\') !== 0) { + $hasNoMagentoClasses = true; + } + } + + if (!$hasNoMagentoClasses) { + unset($conflicts[$for][$scope]); + } + + if ($scope != 'global') { + $isInGlobal = (isset($conflicts[$for]['global']) && count($conflicts[$for]['global'])); + if (!$isInGlobal && count($classes) < 2) { + unset($conflicts[$for][$scope]); + } } - } - if (!$hasNoMagentoClasses) { - unset($conflicts[$origClass]); + if (strpos($for, 'Interface') !== false && count($classes) < 2) { + unset($conflicts[$for][$scope]); + } } + } + + $result = []; + foreach ($conflicts as $for => $scopeClasses) { + foreach ($scopeClasses as $scope => $classes) { + if (!isset($result[$for])) { + $result[$for] = [ + 'classes' => [] + ]; + } - if (strpos($origClass, 'Interface') !== false && count($item['classes']) < 2) { - unset($conflicts[$origClass]); + $result[$for]['classes'] = array_merge($result[$for]['classes'], $classes); } } - return $conflicts; + return $result; } } diff --git a/view/adminhtml/templates/list.phtml b/view/adminhtml/templates/list.phtml index 1795a89..66add9e 100644 --- a/view/adminhtml/templates/list.phtml +++ b/view/adminhtml/templates/list.phtml @@ -6,7 +6,9 @@ * Glory to Ukraine! Glory to the heroes! */ ?> - + getClassRewriteConflicts() ?> @@ -66,4 +68,4 @@
Created by Magefan.
-