Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function getBundle($name, $first = true)
}

/**
* {@inheritDoc}
* {@inheritdoc}
*
* @throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle
*/
Expand Down Expand Up @@ -502,7 +502,7 @@ protected function initializeBundles()
*/
protected function getContainerClass()
{
return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer';
return preg_replace('/(^[0-9]*|[^a-zA-Z0-9_]+)/', '', $this->name.ucfirst($this->environment)).($this->debug ? 'Debug' : '').'ProjectContainer';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I have the following 3 applications, will it still work after this change? Wouldn't it be better to just prefix something?

  • 1app
  • 2app
  • 3app

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. But right now, this "feature" is not supported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to support these edge cases... especially now that Melody has been fixed. it adds a regex for every single request and makes the code less readable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thus, if we fix it here, we need to fix it for the other dumped classes (the url matcher and the url generator)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. no problem. I close the PR

}

/**
Expand Down
29 changes: 29 additions & 0 deletions src/Symfony/Component/HttpKernel/Tests/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,35 @@ public function testGetName()
$this->assertEquals('Fixtures', $kernel->getName());
}

public function getGetNameWithWeirdDirectoryTests()
{
return array(
array('appDevProjectContainer', 'dev', 'app'),
array('appFoobarProjectContainer', 'foo bar', 'app'),
array('appProjectContainer', '..**..', 'app'),
array('ProjectContainer', '..**..', '12345'),
array('DevProjectContainer', 'dev', 12345),
array('ApplicationDevProjectContainer', 'dev', '12345Application'),
array('Application12345DevProjectContainer', 'dev', 'Application12345'),
array('Application12345DevProjectContainer', 'dev', '12345Application12345'),
);
}

/** @dataProvider getGetNameWithWeirdDirectoryTests */
public function testGetContainerClass($expected, $environment, $rootDir)
{
$kernel = new KernelForTest($environment, false);

$p = new \ReflectionProperty($kernel, 'name');
$p->setAccessible(true);
$p->setValue($kernel, $rootDir);

$m = new \ReflectionMethod($kernel, 'getContainerClass');
$m->setAccessible(true);

$this->assertEquals($expected, $m->invoke($kernel));
}

public function testOverrideGetName()
{
$kernel = new KernelForOverrideName('test', true);
Expand Down