2011-01-16 09:17:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Symfony\Component\HttpKernel\DependencyInjection;
|
|
|
|
|
2011-02-28 08:55:53 +00:00
|
|
|
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
2011-01-16 09:17:38 +00:00
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
2011-02-17 22:50:22 +00:00
|
|
|
use Symfony\Component\DependencyInjection\Container;
|
2011-01-16 09:17:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony framework.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-01-16 09:17:38 +00:00
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides useful features shared by many extensions.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
2011-01-16 09:17:38 +00:00
|
|
|
*/
|
2011-02-28 08:55:53 +00:00
|
|
|
abstract class Extension implements ExtensionInterface
|
2011-01-16 09:17:38 +00:00
|
|
|
{
|
|
|
|
protected $classes = array();
|
2011-01-27 13:26:49 +00:00
|
|
|
protected $classMap = array();
|
2011-01-16 09:17:38 +00:00
|
|
|
|
2011-01-27 13:26:49 +00:00
|
|
|
/**
|
|
|
|
* Gets the classes to cache.
|
|
|
|
*
|
|
|
|
* @return array An array of classes
|
|
|
|
*/
|
2011-01-16 09:17:38 +00:00
|
|
|
public function getClassesToCompile()
|
|
|
|
{
|
|
|
|
return $this->classes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-01-27 13:26:49 +00:00
|
|
|
* Adds classes to the class cache.
|
2011-01-16 09:17:38 +00:00
|
|
|
*
|
2011-01-27 13:26:49 +00:00
|
|
|
* @param array $classes An array of classes
|
2011-01-16 09:17:38 +00:00
|
|
|
*/
|
|
|
|
protected function addClassesToCompile(array $classes)
|
|
|
|
{
|
|
|
|
$this->classes = array_merge($this->classes, $classes);
|
|
|
|
}
|
2011-01-27 13:26:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the autoload class map.
|
|
|
|
*
|
|
|
|
* @return array An array of classes
|
|
|
|
*/
|
|
|
|
public function getAutoloadClassMap()
|
|
|
|
{
|
|
|
|
return $this->classMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds classes to the autoload class map.
|
|
|
|
*
|
|
|
|
* @param array $classes An array of classes
|
|
|
|
*/
|
|
|
|
public function addClassesToAutoloadMap(array $classes)
|
|
|
|
{
|
|
|
|
$this->classMap = array_merge($this->classMap, $classes);
|
|
|
|
}
|
2011-02-15 03:14:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the base path for the XSD files.
|
|
|
|
*
|
|
|
|
* @return string The XSD base path
|
|
|
|
*/
|
|
|
|
public function getXsdValidationBasePath()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-20 07:58:37 +00:00
|
|
|
/**
|
|
|
|
* Returns the namespace to be used for this extension (XML namespace).
|
|
|
|
*
|
|
|
|
* @return string The XML namespace
|
|
|
|
*/
|
2011-02-15 03:14:08 +00:00
|
|
|
public function getNamespace()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2011-02-20 07:58:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the recommended alias to use in XML.
|
|
|
|
*
|
|
|
|
* This alias is also the mandatory prefix to use when using YAML.
|
|
|
|
*
|
|
|
|
* @return string The alias
|
|
|
|
*/
|
2011-02-17 22:50:22 +00:00
|
|
|
public function getAlias()
|
|
|
|
{
|
|
|
|
$className = get_class($this);
|
|
|
|
if (substr($className, -9) != 'Extension') {
|
2011-02-20 07:58:37 +00:00
|
|
|
throw new \BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
|
2011-02-17 22:50:22 +00:00
|
|
|
}
|
|
|
|
$classBaseName = substr(strrchr($className, '\\'), 1, -9);
|
2011-02-20 07:58:37 +00:00
|
|
|
|
2011-02-17 22:50:22 +00:00
|
|
|
return Container::underscore($classBaseName);
|
|
|
|
}
|
2011-01-16 09:17:38 +00:00
|
|
|
}
|