[HttpKernel] handle anonymous classes when generating the dumped container class name

This commit is contained in:
Nicolas Grekas 2018-11-26 09:58:02 +01:00
parent 661225075c
commit ac84cb2fbe

View File

@ -225,7 +225,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
public function getBundle($name) public function getBundle($name)
{ {
if (!isset($this->bundles[$name])) { if (!isset($this->bundles[$name])) {
throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, \get_class($this))); $class = \get_class($this);
$class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, $class));
} }
return $this->bundles[$name]; return $this->bundles[$name];
@ -443,7 +446,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
*/ */
protected function getContainerClass() protected function getContainerClass()
{ {
return $this->name.str_replace('\\', '_', \get_class($this)).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; $class = \get_class($this);
$class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).ContainerBuilder::hash($class) : $class;
return $this->name.str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
} }
/** /**