Ver código fonte

Attempt to create a reasonable default based on the rules enforced in
src/Symfony/Component/HttpKernel/bootstrap.php
from commit: 14aa95ba218c9fd6d02e770e279ed854314fea75

Ray 14 anos atrás
pai
commit
8e2d7edb8c

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

@@ -4,6 +4,7 @@ namespace Symfony\Component\HttpKernel\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\Extension\Extension as BaseExtension;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Container;
 
 /*
  * This file is part of the Symfony framework.
@@ -78,4 +79,15 @@ abstract class Extension extends BaseExtension
     {
         return false;
     }
+    
+    public function getAlias()
+    {
+        $className = get_class($this);
+        if (substr($className, -9) != 'Extension') {
+            throw new \BadMethodCallException('This extension does not follow the normal naming, so you must overwrite the getAlias method');
+        }
+        $classBaseName = substr(strrchr($className, '\\'), 1, -9);
+        
+        return Container::underscore($classBaseName);
+    }
 }