Parcourir la source

[Routing] added getContext() accessor

Fabien Potencier il y a 14 ans
Parent
commit
813627bd4c

+ 10 - 0
src/Symfony/Component/Routing/Generator/UrlGenerator.php

@@ -50,6 +50,16 @@ class UrlGenerator implements UrlGeneratorInterface
         $this->context = $context;
         $this->context = $context;
     }
     }
 
 
+    /**
+     * Gets the request context.
+     *
+     * @return RequestContext The context
+     */
+    public function getContext()
+    {
+        return $this->context;
+    }
+
     /**
     /**
      * Generates a URL from the given parameters.
      * Generates a URL from the given parameters.
      *
      *

+ 10 - 0
src/Symfony/Component/Routing/Matcher/UrlMatcher.php

@@ -50,6 +50,16 @@ class UrlMatcher implements UrlMatcherInterface
         $this->context = $context;
         $this->context = $context;
     }
     }
 
 
+    /**
+     * Gets the request context.
+     *
+     * @return RequestContext The context
+     */
+    public function getContext()
+    {
+        return $this->context;
+    }
+
     /**
     /**
      * Tries to match a URL with a set of routes.
      * Tries to match a URL with a set of routes.
      *
      *

+ 12 - 0
src/Symfony/Component/Routing/Router.php

@@ -106,10 +106,22 @@ class Router implements RouterInterface
      */
      */
     public function setContext(RequestContext $context)
     public function setContext(RequestContext $context)
     {
     {
+        $this->context = $context;
+
         $this->getMatcher()->setContext($context);
         $this->getMatcher()->setContext($context);
         $this->getGenerator()->setContext($context);
         $this->getGenerator()->setContext($context);
     }
     }
 
 
+    /**
+     * Gets the request context.
+     *
+     * @return RequestContext The context
+     */
+    public function getContext()
+    {
+        return $this->context;
+    }
+
     /**
     /**
      * Generates a URL from the given parameters.
      * Generates a URL from the given parameters.
      *
      *