浏览代码

[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;
+    }
 }