From 2a1d4ee578c45a20b69bfe52b4fdc57a85268869 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 29 Jul 2013 23:35:43 +0200 Subject: [PATCH] renaming RouteAwareInterface to RouteReferrersInterface to be consistent --- CHANGELOG.md | 1 + ContentAwareGenerator.php | 23 ++++++++-------- ContentRepositoryInterface.php | 2 +- ...terface.php => RouteReferrersInterface.php | 2 +- RouteReferrersWriteInterface.php | 26 +++++++++++++++++++ Tests/Routing/ContentAwareGeneratorTest.php | 6 ++--- VersatileGeneratorInterface.php | 2 +- 7 files changed, 45 insertions(+), 17 deletions(-) rename RouteAwareInterface.php => RouteReferrersInterface.php (95%) create mode 100644 RouteReferrersWriteInterface.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 62885890..074f49d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Changelog 1.1 --- +* **2013-07-29**: Renamed RouteAwareInterface to RouteReferrersInterface for naming consistency * **2013-07-13**: NestedMatcher now expects a FinalMatcherInterface as second argument of the constructor * **2013-04-30**: Dropped Symfony 2.1 support and got rid of ConfigurableUrlMatcher class * **2013-04-05**: [ContentAwareGenerator] Fix locale handling to always respect locale but never have unnecessary ?locale= diff --git a/ContentAwareGenerator.php b/ContentAwareGenerator.php index 9e1173f5..bee3b67d 100644 --- a/ContentAwareGenerator.php +++ b/ContentAwareGenerator.php @@ -42,7 +42,7 @@ public function setContentRepository(ContentRepositoryInterface $contentReposito * @param string $name ignored * @param array $parameters must either contain the field 'route' with a * RouteObjectInterface or the field 'content_id' with a document - * id to get the route for (implementing RouteAwareInterface) + * id to get the route for (implementing RouteReferrersInterface) * * @throws RouteNotFoundException If there is no such route in the database */ @@ -104,7 +104,7 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters) $locale = $this->getLocale($parameters); if (! $this->checkLocaleRequirement($route, $locale)) { $content = $route->getContent(); - if ($content instanceof RouteAwareInterface) { + if ($content instanceof RouteReferrersInterface) { $routes = $content->getRoutes(); $contentRoute = $this->getRouteByLocale($routes, $locale); if ($contentRoute) { @@ -117,8 +117,8 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters) } /** - * Get the route based on the $name that is a RouteAwareInterface or a - * RouteAwareInterface content found in the content repository with the + * Get the route based on the $name that is a RouteReferrersInterface or a + * RouteReferrersInterface content found in the content repository with the * content_id specified in parameters. * * Called in generate when there is no route given in the parameters. @@ -131,7 +131,8 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters) * first route. * * @param mixed $name - * @param array $parameters which should contain a content field containing a RouteAwareInterface object + * @param array $parameters which should contain a content field containing + * a RouteReferrersInterface object * * @return SymfonyRoute the route instance * @@ -139,7 +140,7 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters) */ protected function getRouteByContent($name, &$parameters) { - if ($name instanceof RouteAwareInterface) { + if ($name instanceof RouteReferrersInterface) { $content = $name; } elseif (isset($parameters['content_id']) && null !== $this->contentRepository @@ -148,12 +149,12 @@ protected function getRouteByContent($name, &$parameters) if (empty($content)) { throw new RouteNotFoundException('The content repository found nothing at id ' . $parameters['content_id']); } - if (!$content instanceof RouteAwareInterface) { - throw new RouteNotFoundException('Content repository did not return a RouteAwareInterface for id ' . $parameters['content_id']); + if (!$content instanceof RouteReferrersInterface) { + throw new RouteNotFoundException('Content repository did not return a RouteReferrersInterface for id ' . $parameters['content_id']); } } else { $hint = is_object($name) ? get_class($name) : gettype($name); - throw new RouteNotFoundException("The route name argument '$hint' is not RouteAwareInterface and there is no 'content_id' parameter"); + throw new RouteNotFoundException("The route name argument '$hint' is not RouteReferrersInterface and there is no 'content_id' parameter"); } $routes = $content->getRoutes(); @@ -233,7 +234,7 @@ protected function getLocale($parameters) */ public function supports($name) { - return ! $name || parent::supports($name) || $name instanceof RouteAwareInterface; + return ! $name || parent::supports($name) || $name instanceof RouteReferrersInterface; } /** @@ -245,7 +246,7 @@ public function getRouteDebugMessage($name, array $parameters = array()) return 'Content id ' . $parameters['content_id']; } - if ($name instanceof RouteAwareInterface) { + if ($name instanceof RouteReferrersInterface) { return 'Route aware content ' . $name; } diff --git a/ContentRepositoryInterface.php b/ContentRepositoryInterface.php index d8c5cb43..eba47b97 100644 --- a/ContentRepositoryInterface.php +++ b/ContentRepositoryInterface.php @@ -16,7 +16,7 @@ interface ContentRepositoryInterface /** * Return a content object by it's id or null if there is none. * - * If the returned content implements RouteAwareInterface, it will be used + * If the returned content implements RouteReferrersInterface, it will be used * to get the route from it to generate an URL. * * @param string $id id of the content object diff --git a/RouteAwareInterface.php b/RouteReferrersInterface.php similarity index 95% rename from RouteAwareInterface.php rename to RouteReferrersInterface.php index aaec32d6..b2c19bec 100644 --- a/RouteAwareInterface.php +++ b/RouteReferrersInterface.php @@ -6,7 +6,7 @@ * Interface to be implemented by content that wants to be compatible with the * DynamicRouter */ -interface RouteAwareInterface +interface RouteReferrersInterface { /** * Get the routes that point to this content. diff --git a/RouteReferrersWriteInterface.php b/RouteReferrersWriteInterface.php new file mode 100644 index 00000000..0f336948 --- /dev/null +++ b/RouteReferrersWriteInterface.php @@ -0,0 +1,26 @@ +contentDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\RouteAwareInterface'); + $this->contentDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\RouteReferrersInterface'); $this->routeDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile')); $this->routeCompiled = $this->buildMock('Symfony\\Component\\Routing\\CompiledRoute'); $this->provider = $this->buildMock("Symfony\\Cmf\\Component\\Routing\\RouteProviderInterface"); @@ -367,7 +367,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa } } -class RouteAware implements RouteAwareInterface +class RouteAware implements RouteReferrersInterface { public function getRoutes() { diff --git a/VersatileGeneratorInterface.php b/VersatileGeneratorInterface.php index 24f8210a..36888256 100644 --- a/VersatileGeneratorInterface.php +++ b/VersatileGeneratorInterface.php @@ -29,7 +29,7 @@ public function supports($name); * * @param mixed $name * @param array $parameters which should contain a content field containing - * a RouteAwareInterface object + * a RouteReferrersInterface object * * @return string */