Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / http-kernel / Bundle / Bundle.php
index 13c2d941d02f807f5a7ad32ce5e4b48a7acc4dc3..3b4e156c7a71615e91ac1bdf12fe49f3e481c7dc 100644 (file)
@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\HttpKernel\Bundle;
 
-use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\ContainerAwareTrait;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Container;
 use Symfony\Component\Console\Application;
@@ -26,13 +26,12 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
  */
 abstract class Bundle implements BundleInterface
 {
-    /**
-     * @var ContainerInterface
-     */
-    protected $container;
+    use ContainerAwareTrait;
+
     protected $name;
     protected $extension;
     protected $path;
+    private $namespace;
 
     /**
      * Boots the Bundle.
@@ -62,16 +61,6 @@ abstract class Bundle implements BundleInterface
     {
     }
 
-    /**
-     * Sets the container.
-     *
-     * @param ContainerInterface|null $container A ContainerInterface instance or null
-     */
-    public function setContainer(ContainerInterface $container = null)
-    {
-        $this->container = $container;
-    }
-
     /**
      * Returns the bundle's container extension.
      *
@@ -118,9 +107,11 @@ abstract class Bundle implements BundleInterface
      */
     public function getNamespace()
     {
-        $class = get_class($this);
+        if (null === $this->namespace) {
+            $this->parseClassName();
+        }
 
-        return substr($class, 0, strrpos($class, '\\'));
+        return $this->namespace;
     }
 
     /**
@@ -154,14 +145,11 @@ abstract class Bundle implements BundleInterface
      */
     final public function getName()
     {
-        if (null !== $this->name) {
-            return $this->name;
+        if (null === $this->name) {
+            $this->parseClassName();
         }
 
-        $name = get_class($this);
-        $pos = strrpos($name, '\\');
-
-        return $this->name = false === $pos ? $name : substr($name, $pos + 1);
+        return $this->name;
     }
 
     /**
@@ -230,4 +218,13 @@ abstract class Bundle implements BundleInterface
             return new $class();
         }
     }
+
+    private function parseClassName()
+    {
+        $pos = strrpos(static::class, '\\');
+        $this->namespace = false === $pos ? '' : substr(static::class, 0, $pos);
+        if (null === $this->name) {
+            $this->name = false === $pos ? static::class : substr(static::class, $pos + 1);
+        }
+    }
 }