Skip to content

Commit ad03d7c

Browse files
committed
last round of cleaning up interface names
1 parent 669be07 commit ad03d7c

7 files changed

+62
-32
lines changed

CHANGELOG.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ Changelog
44
1.1
55
---
66

7-
* **2013-07-31**: DynamicRouter now accepts an EventDispatcher to trigger a RouteMatchEvent right before the matching starts
8-
* **2013-07-29**: Renamed RouteAwareInterface to RouteReferrersInterface for naming consistency
9-
* **2013-07-13**: NestedMatcher now expects a FinalMatcherInterface as second argument of the constructor
10-
* **2013-04-30**: Dropped Symfony 2.1 support and got rid of ConfigurableUrlMatcher class
11-
* **2013-04-05**: [ContentAwareGenerator] Fix locale handling to always respect locale but never have unnecessary ?locale=
7+
* **2013-07-31**: DynamicRouter now accepts an EventDispatcher to trigger a
8+
RouteMatchEvent right before the matching starts
9+
* **2013-07-29**: Renamed RouteAwareInterface to RouteReferrersReadInterface
10+
for naming consistency and added RouteReferrersInterface for write access.
11+
* **2013-07-13**: NestedMatcher now expects a FinalMatcherInterface as second
12+
argument of the constructor
13+
* **2013-04-30**: Dropped Symfony 2.1 support and got rid of
14+
ConfigurableUrlMatcher class
15+
* **2013-04-05**: [ContentAwareGenerator] Fix locale handling to always respect
16+
locale but never have unnecessary ?locale=

ContentAwareGenerator.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function setContentRepository(ContentRepositoryInterface $contentReposito
4242
* @param string $name ignored
4343
* @param array $parameters must either contain the field 'route' with a
4444
* RouteObjectInterface or the field 'content_id' with a document
45-
* id to get the route for (implementing RouteReferrersInterface)
45+
* id to get the route for (implementing RouteReferrersReadInterface)
4646
*
4747
* @throws RouteNotFoundException If there is no such route in the database
4848
*/
@@ -104,7 +104,7 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters)
104104
$locale = $this->getLocale($parameters);
105105
if (! $this->checkLocaleRequirement($route, $locale)) {
106106
$content = $route->getContent();
107-
if ($content instanceof RouteReferrersInterface) {
107+
if ($content instanceof RouteReferrersReadInterface) {
108108
$routes = $content->getRoutes();
109109
$contentRoute = $this->getRouteByLocale($routes, $locale);
110110
if ($contentRoute) {
@@ -117,9 +117,10 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters)
117117
}
118118

119119
/**
120-
* Get the route based on the $name that is a RouteReferrersInterface or a
121-
* RouteReferrersInterface content found in the content repository with the
122-
* content_id specified in parameters.
120+
* Get the route based on the $name that is an object implementing
121+
* RouteReferrersReadInterface or a content found in the content repository
122+
* with the content_id specified in parameters that is an instance of
123+
* RouteReferrersReadInterface.
123124
*
124125
* Called in generate when there is no route given in the parameters.
125126
*
@@ -132,15 +133,15 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters)
132133
*
133134
* @param mixed $name
134135
* @param array $parameters which should contain a content field containing
135-
* a RouteReferrersInterface object
136+
* a RouteReferrersReadInterface object
136137
*
137138
* @return SymfonyRoute the route instance
138139
*
139140
* @throws RouteNotFoundException if no route can be determined
140141
*/
141142
protected function getRouteByContent($name, &$parameters)
142143
{
143-
if ($name instanceof RouteReferrersInterface) {
144+
if ($name instanceof RouteReferrersReadInterface) {
144145
$content = $name;
145146
} elseif (isset($parameters['content_id'])
146147
&& null !== $this->contentRepository
@@ -149,12 +150,12 @@ protected function getRouteByContent($name, &$parameters)
149150
if (empty($content)) {
150151
throw new RouteNotFoundException('The content repository found nothing at id ' . $parameters['content_id']);
151152
}
152-
if (!$content instanceof RouteReferrersInterface) {
153-
throw new RouteNotFoundException('Content repository did not return a RouteReferrersInterface for id ' . $parameters['content_id']);
153+
if (!$content instanceof RouteReferrersReadInterface) {
154+
throw new RouteNotFoundException('Content repository did not return a RouteReferrersReadInterface instance for id ' . $parameters['content_id']);
154155
}
155156
} else {
156157
$hint = is_object($name) ? get_class($name) : gettype($name);
157-
throw new RouteNotFoundException("The route name argument '$hint' is not RouteReferrersInterface and there is no 'content_id' parameter");
158+
throw new RouteNotFoundException("The route name argument '$hint' is not RouteReferrersReadInterface instance and there is no 'content_id' parameter");
158159
}
159160

160161
$routes = $content->getRoutes();
@@ -234,7 +235,7 @@ protected function getLocale($parameters)
234235
*/
235236
public function supports($name)
236237
{
237-
return ! $name || parent::supports($name) || $name instanceof RouteReferrersInterface;
238+
return ! $name || parent::supports($name) || $name instanceof RouteReferrersReadInterface;
238239
}
239240

240241
/**
@@ -246,7 +247,7 @@ public function getRouteDebugMessage($name, array $parameters = array())
246247
return 'Content id ' . $parameters['content_id'];
247248
}
248249

249-
if ($name instanceof RouteReferrersInterface) {
250+
if ($name instanceof RouteReferrersReadInterface) {
250251
return 'Route aware content ' . $name;
251252
}
252253

ContentRepositoryInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ interface ContentRepositoryInterface
1616
/**
1717
* Return a content object by it's id or null if there is none.
1818
*
19-
* If the returned content implements RouteReferrersInterface, it will be used
20-
* to get the route from it to generate an URL.
19+
* If the returned content implements RouteReferrersReadInterface, it will
20+
* be used to get the route from it to generate an URL.
2121
*
2222
* @param string $id id of the content object
2323
*

RouteReferrersInterface.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22

33
namespace Symfony\Cmf\Component\Routing;
44

5+
use Symfony\Component\Routing\Route;
6+
57
/**
6-
* Interface to be implemented by content that wants to be compatible with the
7-
* DynamicRouter
8+
* Interface to be implemented by content that exposes editable route
9+
* referrers.
810
*/
9-
interface RouteReferrersInterface
11+
interface RouteReferrersInterface extends RouteReferrersReadInterface
1012
{
1113
/**
12-
* Get the routes that point to this content.
14+
* Add a route to the collection.
1315
*
14-
* Note: For PHPCR ODM, as explained in RouteObjectInterface the route must use the
15-
* routeContent field to store the reference to the content so you can get the routes with
16-
* Referrers(referringDocument="Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route", referencedBy="routeContent")
16+
* @param Route $route
17+
*/
18+
public function addRoute($route);
19+
20+
/**
21+
* Remove a route from the collection.
1722
*
18-
* @return \Symfony\Component\Routing\Route[] Route instances that point to this content
23+
* @param Route $route
1924
*/
20-
public function getRoutes();
25+
public function removeRoute($route);
2126
}

RouteReferrersReadInterface.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Symfony\Cmf\Component\Routing;
4+
5+
use Symfony\Component\Routing\Route;
6+
7+
/**
8+
* Interface to be implemented by content that wants to be support route generation
9+
* from content with the DynamicRouter by providing the routes that point to it.
10+
*/
11+
interface RouteReferrersReadInterface
12+
{
13+
/**
14+
* Get the routes that point to this content.
15+
*
16+
* @return Route[] Route instances that point to this content
17+
*/
18+
public function getRoutes();
19+
}

Tests/Routing/ContentAwareGeneratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Symfony\Cmf\Component\Routing\Tests\Routing;
44

5-
use Symfony\Cmf\Component\Routing\RouteReferrersInterface;
5+
use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface;
66

77
use Symfony\Cmf\Component\Routing\ContentAwareGenerator;
88
use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase;
@@ -22,7 +22,7 @@ class ContentAwareGeneratorTest extends CmfUnitTestCase
2222

2323
public function setUp()
2424
{
25-
$this->contentDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\RouteReferrersInterface');
25+
$this->contentDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\RouteReferrersReadInterface');
2626
$this->routeDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile'));
2727
$this->routeCompiled = $this->buildMock('Symfony\\Component\\Routing\\CompiledRoute');
2828
$this->provider = $this->buildMock("Symfony\\Cmf\\Component\\Routing\\RouteProviderInterface");
@@ -367,7 +367,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
367367
}
368368
}
369369

370-
class RouteAware implements RouteReferrersInterface
370+
class RouteAware implements RouteReferrersReadInterface
371371
{
372372
public function getRoutes()
373373
{

VersatileGeneratorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function supports($name);
2929
*
3030
* @param mixed $name
3131
* @param array $parameters which should contain a content field containing
32-
* a RouteReferrersInterface object
32+
* a RouteReferrersReadInterface object
3333
*
3434
* @return string
3535
*/

0 commit comments

Comments
 (0)