removed the need to define getNamespace() and getPath() in bundles
This commit is contained in:
parent
523e652d9d
commit
e5403490e7
@ -20,19 +20,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
*/
|
*/
|
||||||
class CompatAssetsBundle extends Bundle
|
class CompatAssetsBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,20 +31,4 @@ class DoctrineBundle extends Bundle
|
|||||||
|
|
||||||
$container->addCompilerPass(new RegisterEventListenersAndSubscribersPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION);
|
$container->addCompilerPass(new RegisterEventListenersAndSubscribersPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,19 +6,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
|
|
||||||
class AnnotationsBundle extends Bundle
|
class AnnotationsBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
}
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -6,19 +6,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
|
|
||||||
class AnnotationsBundle extends Bundle
|
class AnnotationsBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
}
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -6,19 +6,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
|
|
||||||
class XmlBundle extends Bundle
|
class XmlBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,19 +6,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
|
|
||||||
class YamlBundle extends Bundle
|
class YamlBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,19 +21,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
*/
|
*/
|
||||||
class DoctrineMigrationsBundle extends Bundle
|
class DoctrineMigrationsBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -35,20 +35,4 @@ class DoctrineMongoDBBundle extends Bundle
|
|||||||
$container->addCompilerPass(new CreateProxyDirectoryPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
$container->addCompilerPass(new CreateProxyDirectoryPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||||
$container->addCompilerPass(new CreateHydratorDirectoryPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
$container->addCompilerPass(new CreateHydratorDirectoryPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,19 +6,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
|
|
||||||
class AnnotationsBundle extends Bundle
|
class AnnotationsBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,19 +6,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
|
|
||||||
class XmlBundle extends Bundle
|
class XmlBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,19 +6,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
|
|
||||||
class YamlBundle extends Bundle
|
class YamlBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ class TemplatePathsCacheWarmer extends CacheWarmer
|
|||||||
$prefix = '/Resources/views';
|
$prefix = '/Resources/views';
|
||||||
$templates = array();
|
$templates = array();
|
||||||
foreach ($this->kernel->getBundles() as $name => $bundle) {
|
foreach ($this->kernel->getBundles() as $name => $bundle) {
|
||||||
if (!is_dir($dir = $bundle->getNormalizedPath().$prefix)) {
|
if (!is_dir($dir = $bundle->getPath().$prefix)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,20 +80,4 @@ class FrameworkBundle extends Bundle
|
|||||||
$container->addCompilerPass(new TranslatorPass());
|
$container->addCompilerPass(new TranslatorPass());
|
||||||
$container->addCompilerPass(new AddCacheWarmerPass());
|
$container->addCompilerPass(new AddCacheWarmerPass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,19 +6,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
|
|
||||||
class {{ bundle }} extends Bundle
|
class {{ bundle }} extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return strtr(__DIR__, '\\', '/');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,20 +27,4 @@ class FabpotFooBundle extends Bundle
|
|||||||
{
|
{
|
||||||
return 'SensioFooBundle';
|
return 'SensioFooBundle';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,19 +20,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
*/
|
*/
|
||||||
class FooBundle extends Bundle
|
class FooBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,19 +20,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
*/
|
*/
|
||||||
class SensioCmsFooBundle extends Bundle
|
class SensioCmsFooBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,19 +20,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
*/
|
*/
|
||||||
class SensioFooBundle extends Bundle
|
class SensioFooBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -30,20 +30,4 @@ class SecurityBundle extends Bundle
|
|||||||
$container->addCompilerPass(new AddSecurityVotersPass());
|
$container->addCompilerPass(new AddSecurityVotersPass());
|
||||||
$container->addCompilerPass(new AddAuthenticationProvidersPass());
|
$container->addCompilerPass(new AddAuthenticationProvidersPass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,19 +20,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
*/
|
*/
|
||||||
class SwiftmailerBundle extends Bundle
|
class SwiftmailerBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,20 +28,4 @@ class TwigBundle extends Bundle
|
|||||||
|
|
||||||
$container->addCompilerPass(new TwigEnvironmentPass());
|
$container->addCompilerPass(new TwigEnvironmentPass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,19 +20,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
*/
|
*/
|
||||||
class WebProfilerBundle extends Bundle
|
class WebProfilerBundle extends Bundle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,20 +28,4 @@ class ZendBundle extends Bundle
|
|||||||
|
|
||||||
$container->addCompilerPass(new ZendLoggerWriterPass());
|
$container->addCompilerPass(new ZendLoggerWriterPass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return __NAMESPACE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPath()
|
|
||||||
{
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ use Symfony\Component\Finder\Finder;
|
|||||||
abstract class Bundle extends ContainerAware implements BundleInterface
|
abstract class Bundle extends ContainerAware implements BundleInterface
|
||||||
{
|
{
|
||||||
protected $name;
|
protected $name;
|
||||||
|
protected $reflected;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boots the Bundle.
|
* Boots the Bundle.
|
||||||
@ -40,6 +41,34 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Bundle namespace.
|
||||||
|
*
|
||||||
|
* @return string The Bundle namespace
|
||||||
|
*/
|
||||||
|
public function getNamespace()
|
||||||
|
{
|
||||||
|
if (null === $this->reflected) {
|
||||||
|
$this->reflected = new \ReflectionObject($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->reflected->getNamespaceName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Bundle directory path.
|
||||||
|
*
|
||||||
|
* @return string The Bundle absolute path
|
||||||
|
*/
|
||||||
|
public function getPath()
|
||||||
|
{
|
||||||
|
if (null === $this->reflected) {
|
||||||
|
$this->reflected = new \ReflectionObject($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return strtr(dirname($this->reflected->getFileName()), '\\', '/');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the bundle parent name.
|
* Returns the bundle parent name.
|
||||||
*
|
*
|
||||||
@ -67,18 +96,6 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
|||||||
return $this->name = false === $pos ? $name : substr($name, $pos + 1);
|
return $this->name = false === $pos ? $name : substr($name, $pos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Bundle directory path.
|
|
||||||
*
|
|
||||||
* The path should always be returned as a Unix path (with /).
|
|
||||||
*
|
|
||||||
* @return string The Bundle absolute path
|
|
||||||
*/
|
|
||||||
final public function getNormalizedPath()
|
|
||||||
{
|
|
||||||
return strtr($this->getPath(), '\\', '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds and registers Dependency Injection Container extensions.
|
* Finds and registers Dependency Injection Container extensions.
|
||||||
*
|
*
|
||||||
@ -91,7 +108,7 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
|||||||
*/
|
*/
|
||||||
public function registerExtensions(ContainerBuilder $container)
|
public function registerExtensions(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
if (!$dir = realpath($this->getNormalizedPath().'/DependencyInjection')) {
|
if (!$dir = realpath($this->getPath().'/DependencyInjection')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +135,7 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
|||||||
*/
|
*/
|
||||||
public function registerCommands(Application $application)
|
public function registerCommands(Application $application)
|
||||||
{
|
{
|
||||||
if (!$dir = realpath($this->getNormalizedPath().'/Command')) {
|
if (!$dir = realpath($this->getPath().'/Command')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,14 +49,6 @@ interface BundleInterface
|
|||||||
*/
|
*/
|
||||||
function getNamespace();
|
function getNamespace();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Bundle directory path.
|
|
||||||
*
|
|
||||||
* @return string The Bundle absolute path
|
|
||||||
*/
|
|
||||||
function getPath();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Bundle directory path.
|
* Gets the Bundle directory path.
|
||||||
*
|
*
|
||||||
@ -64,5 +56,5 @@ interface BundleInterface
|
|||||||
*
|
*
|
||||||
* @return string The Bundle absolute path
|
* @return string The Bundle absolute path
|
||||||
*/
|
*/
|
||||||
function getNormalizedPath();
|
function getPath();
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ abstract class Kernel implements KernelInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->getBundle($bundle, false) as $bundle) {
|
foreach ($this->getBundle($bundle, false) as $bundle) {
|
||||||
if (file_exists($file = $bundle->getNormalizedPath().'/'.$path)) {
|
if (file_exists($file = $bundle->getPath().'/'.$path)) {
|
||||||
if ($first) {
|
if ($first) {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ class Container implements ContainerInterface
|
|||||||
$ids = array();
|
$ids = array();
|
||||||
$r = new \ReflectionClass($this);
|
$r = new \ReflectionClass($this);
|
||||||
foreach ($r->getMethods() as $method) {
|
foreach ($r->getMethods() as $method) {
|
||||||
if (preg_match('/^get(.+)Service$/', $name = $method->getName(), $match)) {
|
if (preg_match('/^get(.+)Service$/', $method->getName(), $match)) {
|
||||||
$ids[] = self::underscore($match[1]);
|
$ids[] = self::underscore($match[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,7 +229,6 @@ interface BundleInterface
|
|||||||
function getName();
|
function getName();
|
||||||
function getNamespace();
|
function getNamespace();
|
||||||
function getPath();
|
function getPath();
|
||||||
function getNormalizedPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
namespace Symfony\Component\HttpKernel\Bundle
|
namespace Symfony\Component\HttpKernel\Bundle
|
||||||
@ -241,12 +240,27 @@ use Symfony\Component\Finder\Finder;
|
|||||||
abstract class Bundle extends ContainerAware implements BundleInterface
|
abstract class Bundle extends ContainerAware implements BundleInterface
|
||||||
{
|
{
|
||||||
protected $name;
|
protected $name;
|
||||||
|
protected $reflected;
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public function shutdown()
|
public function shutdown()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
public function getNamespace()
|
||||||
|
{
|
||||||
|
if (null === $this->reflected) {
|
||||||
|
$this->reflected = new \ReflectionObject($this);
|
||||||
|
}
|
||||||
|
return $this->reflected->getNamespaceName();
|
||||||
|
}
|
||||||
|
public function getPath()
|
||||||
|
{
|
||||||
|
if (null === $this->reflected) {
|
||||||
|
$this->reflected = new \ReflectionObject($this);
|
||||||
|
}
|
||||||
|
return strtr(dirname($this->reflected->getFileName()), '\\', '/');
|
||||||
|
}
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -260,13 +274,9 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
|||||||
$pos = strrpos($name, '\\');
|
$pos = strrpos($name, '\\');
|
||||||
return $this->name = false === $pos ? $name : substr($name, $pos + 1);
|
return $this->name = false === $pos ? $name : substr($name, $pos + 1);
|
||||||
}
|
}
|
||||||
final public function getNormalizedPath()
|
|
||||||
{
|
|
||||||
return strtr($this->getPath(), '\\', '/');
|
|
||||||
}
|
|
||||||
public function registerExtensions(ContainerBuilder $container)
|
public function registerExtensions(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
if (!$dir = realpath($this->getNormalizedPath().'/DependencyInjection')) {
|
if (!$dir = realpath($this->getPath().'/DependencyInjection')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$finder = new Finder();
|
$finder = new Finder();
|
||||||
@ -279,7 +289,7 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
|||||||
}
|
}
|
||||||
public function registerCommands(Application $application)
|
public function registerCommands(Application $application)
|
||||||
{
|
{
|
||||||
if (!$dir = realpath($this->getNormalizedPath().'/Command')) {
|
if (!$dir = realpath($this->getPath().'/Command')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$finder = new Finder();
|
$finder = new Finder();
|
||||||
@ -577,7 +587,7 @@ abstract class Kernel implements KernelInterface
|
|||||||
$files[] = $file;
|
$files[] = $file;
|
||||||
}
|
}
|
||||||
foreach ($this->getBundle($bundle, false) as $bundle) {
|
foreach ($this->getBundle($bundle, false) as $bundle) {
|
||||||
if (file_exists($file = $bundle->getNormalizedPath().'/'.$path)) {
|
if (file_exists($file = $bundle->getPath().'/'.$path)) {
|
||||||
if ($first) {
|
if ($first) {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ abstract class Kernel implements KernelInterface
|
|||||||
$files[] = $file;
|
$files[] = $file;
|
||||||
}
|
}
|
||||||
foreach ($this->getBundle($bundle, false) as $bundle) {
|
foreach ($this->getBundle($bundle, false) as $bundle) {
|
||||||
if (file_exists($file = $bundle->getNormalizedPath().'/'.$path)) {
|
if (file_exists($file = $bundle->getPath().'/'.$path)) {
|
||||||
if ($first) {
|
if ($first) {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Tests\Component\HttpKernel\Bundle;
|
|
||||||
|
|
||||||
class BundleTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
public function testGetNormalizedPathReturnsANormalizedPath()
|
|
||||||
{
|
|
||||||
$bundle = $this
|
|
||||||
->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')
|
|
||||||
->setMethods(array('getPath'))
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMockForAbstractClass()
|
|
||||||
;
|
|
||||||
|
|
||||||
$bundle
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getPath')
|
|
||||||
->will($this->returnValue('path\\to\\foo\\bar'))
|
|
||||||
;
|
|
||||||
|
|
||||||
$this->assertEquals('path/to/foo/bar', $bundle->getNormalizedPath());
|
|
||||||
}
|
|
||||||
}
|
|
@ -255,7 +255,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$bundle = $this
|
$bundle = $this
|
||||||
->getMockBuilder('Symfony\Tests\Component\HttpKernel\BundleForTest')
|
->getMockBuilder('Symfony\Tests\Component\HttpKernel\BundleForTest')
|
||||||
->setMethods(array('getNormalizedPath', 'getParent', 'getName'))
|
->setMethods(array('getPath', 'getParent', 'getName'))
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$bundle
|
$bundle
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getNormalizedPath')
|
->method('getPath')
|
||||||
->will($this->returnValue(strtr($dir, '\\', '/')))
|
->will($this->returnValue(strtr($dir, '\\', '/')))
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user