Преглед изворни кода

[DependencyInjection] made getXsdValidationBasePath() and getNamespace() methods from DIC Extension class optional

This has been changed so that people that do not use XML for their own extensions do
not need to bother implementing these two methods.
Fabien Potencier пре 14 година
родитељ
комит
4972bf6350

+ 5 - 1
src/Symfony/Component/DependencyInjection/ContainerBuilder.php

@@ -54,7 +54,11 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
      */
     static public function registerExtension(ExtensionInterface $extension)
     {
-        static::$extensions[$extension->getAlias()] = static::$extensions[$extension->getNamespace()] = $extension;
+        static::$extensions[$extension->getAlias()] = $extension;
+
+        if (false !== $extension->getNamespace()) {
+            static::$extensions[$extension->getNamespace()] = $extension;
+        }
     }
 
     /**

+ 15 - 0
src/Symfony/Component/HttpKernel/DependencyInjection/Extension.php

@@ -63,4 +63,19 @@ abstract class Extension extends BaseExtension
     {
         $this->classMap = array_merge($this->classMap, $classes);
     }
+
+    /**
+     * Returns the base path for the XSD files.
+     *
+     * @return string The XSD base path
+     */
+    public function getXsdValidationBasePath()
+    {
+        return false;
+    }
+
+    public function getNamespace()
+    {
+        return false;
+    }
 }