Skip to content

Commit

Permalink
changed all extensions to use the default Extension::getAlias() impl
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Feb 20, 2011
1 parent 8e2d7ed commit 23e9386
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bundle\AsseticBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\Config\FileLocator;
Expand Down Expand Up @@ -110,9 +110,4 @@ public function getNamespace()
{
return 'http://www.symfony-project.org/schema/dic/assetic';
}

public function getAlias()
{
return 'assetic';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -576,16 +576,4 @@ public function getNamespace()
{
return 'http://www.symfony-project.org/schema/dic/doctrine';
}

/**
* Returns the recommended alias to use in XML.
*
* This alias is also the mandatory prefix to use when using YAML.
*
* @return string The alias
*/
public function getAlias()
{
return 'doctrine';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,4 @@ public function getXsdValidationBasePath()
{
return __DIR__.'/../Resources/config/schema';
}

/**
* Returns the recommended alias to use in XML.
*
* This alias is also the mandatory prefix to use when using YAML.
*
* @return string The alias
*/
public function getAlias()
{
return 'doctrine_mongo_db';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,4 @@ public function getNamespace()
{
return 'http://www.symfony-project.org/schema/dic/symfony';
}

public function getAlias()
{
return 'framework';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,6 @@ public function load(array $configs, ContainerBuilder $container)
));
}

/**
* Returns the base path for the XSD files.
*
* @return string The XSD base path
*/
public function getXsdValidationBasePath()
{
return __DIR__.'/../Resources/config/schema';
}

public function getNamespace()
{
return 'http://www.symfony-project.org/schema/dic/security';
}

public function getAlias()
{
return 'security';
}

protected function aclLoad($config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config')));
Expand Down Expand Up @@ -591,4 +571,20 @@ protected function createListenerFactories(ContainerBuilder $container, $config)

return $this->factories = $factories;
}


/**
* Returns the base path for the XSD files.
*
* @return string The XSD base path
*/
public function getXsdValidationBasePath()
{
return __DIR__.'/../Resources/config/schema';
}

public function getNamespace()
{
return 'http://www.symfony-project.org/schema/dic/security';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,4 @@ public function getNamespace()
{
return 'http://www.symfony-project.org/schema/dic/swiftmailer';
}

/**
* Returns the recommended alias to use in XML.
*
* This alias is also the mandatory prefix to use when using YAML.
*
* @return string The alias
*/
public function getAlias()
{
return 'swiftmailer';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,4 @@ public function getNamespace()
{
return 'http://www.symfony-project.org/schema/dic/twig';
}

public function getAlias()
{
return 'twig';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,4 @@ public function getNamespace()
{
return 'http://www.symfony-project.org/schema/dic/webprofiler';
}

public function getAlias()
{
return 'web_profiler';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,4 @@ public function getNamespace()
{
return 'http://www.symfony-project.org/schema/dic/zend';
}

public function getAlias()
{
return 'zend';
}
}
18 changes: 15 additions & 3 deletions src/Symfony/Component/HttpKernel/DependencyInjection/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,31 @@ public function getXsdValidationBasePath()
return false;
}

/**
* Returns the namespace to be used for this extension (XML namespace).
*
* @return string The XML namespace
*/
public function getNamespace()
{
return false;
}


/**
* Returns the recommended alias to use in XML.
*
* This alias is also the mandatory prefix to use when using YAML.
*
* @return string The alias
*/
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');
throw new \BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
}
$classBaseName = substr(strrchr($className, '\\'), 1, -9);

return Container::underscore($classBaseName);
}
}

0 comments on commit 23e9386

Please sign in to comment.