diff --git a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php index ba7ebdf49dc43..032b67c89a7a3 100644 --- a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php +++ b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php @@ -44,14 +44,14 @@ class ComponentRegistrar implements ComponentRegistrarInterface */ public static function register($type, $componentName, $path) { - self::validateType($type); - if (isset(self::$paths[$type][$componentName])) { + if (!isset(self::$paths[$type][$componentName])) { + self::validateType($type); + self::$paths[$type][$componentName] = str_replace('\\', '/', $path); + } elseif (str_replace('\\', '/', $path) !== self::$paths[$type][$componentName]) { throw new \LogicException( ucfirst($type) . ' \'' . $componentName . '\' from \'' . $path . '\' ' . 'has been already defined in \'' . self::$paths[$type][$componentName] . '\'.' ); - } else { - self::$paths[$type][$componentName] = str_replace('\\', '/', $path); } } diff --git a/lib/internal/Magento/Framework/Component/Test/Unit/ComponentRegistrarTest.php b/lib/internal/Magento/Framework/Component/Test/Unit/ComponentRegistrarTest.php index fe68f9cbd18bd..49f065b0918c7 100644 --- a/lib/internal/Magento/Framework/Component/Test/Unit/ComponentRegistrarTest.php +++ b/lib/internal/Magento/Framework/Component/Test/Unit/ComponentRegistrarTest.php @@ -42,6 +42,12 @@ public function testGetPathsForModule() $this->assertContains($expected['test_module_one'], $this->object->getPaths(ComponentRegistrar::MODULE)); $this->assertContains($expected['test_module_two'], $this->object->getPaths(ComponentRegistrar::MODULE)); } + + public function testDuplicateRegistrationIsNullOp() + { + ComponentRegistrar::register(ComponentRegistrar::MODULE, "test_module_three", "some/path/name/three"); + ComponentRegistrar::register(ComponentRegistrar::MODULE, "test_module_three", "some/path/name/three"); + } /** * @expectedException \LogicException