Skip to content

Commit d8558f5

Browse files
committed
updated for RouteCollection support
1 parent 3dbf813 commit d8558f5

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

Doctrine/Orm/RouteProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ public function getRouteByName($name, $parameters = array())
7373
/**
7474
* {@inheritDoc}
7575
*/
76-
public function getRoutesByNames($names, $parameters = array())
76+
public function getRoutesByNames($names = null, $parameters = array())
7777
{
78+
if (null === $names) {
79+
return $this->getRoutesRepository()->findAll();
80+
}
81+
7882
$routes = array();
7983
foreach ($names as $name) {
8084
try {

Doctrine/Phpcr/RouteProvider.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr;
1414

15+
use PHPCR\Query\QueryInterface;
1516
use PHPCR\RepositoryException;
1617

1718
use Symfony\Component\Routing\Route as SymfonyRoute;
@@ -135,11 +136,40 @@ public function getRouteByName($name, $parameters = array())
135136
return $route;
136137
}
137138

139+
/**
140+
* Get list of route names
141+
*
142+
* @return array
143+
*/
144+
private function getRouteNames()
145+
{
146+
$dm = $this->getObjectManager();
147+
$sql2 = 'SELECT * FROM [nt:unstructured] WHERE [phpcr:classparents] = '.$dm->quote('Symfony\Component\Routing\Route');
148+
149+
if ('' !== $this->idPrefix) {
150+
$sql2.= ' AND ISDESCENDANTNODE('.$dm->quote($this->idPrefix).')';
151+
}
152+
153+
$query = $dm->createPhpcrQuery($sql2, QueryInterface::JCR_SQL2);
154+
$result = $query->execute();
155+
156+
$names = array();
157+
foreach ($result as $row) {
158+
$names[] = $row->getPath();
159+
}
160+
161+
return $names;
162+
}
163+
138164
/**
139165
* {@inheritDoc}
140166
*/
141-
public function getRoutesByNames($names, $parameters = array())
167+
public function getRoutesByNames($names = null, $parameters = array())
142168
{
169+
if (null === $names) {
170+
$names = $this->getRouteNames();
171+
}
172+
143173
if ('' !== $this->idPrefix) {
144174
foreach ($names as $key => $name) {
145175
if (0 !== strpos($name, $this->idPrefix)) {
@@ -158,5 +188,4 @@ public function getRoutesByNames($names, $parameters = array())
158188

159189
return $collection;
160190
}
161-
162191
}

Resources/config/routing-dynamic.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<argument type="service" id="cmf_routing.generator" />
6868
<argument>%cmf_routing.uri_filter_regexp%</argument>
6969
<argument type="service" id="event_dispatcher" on-invalid="ignore"/>
70+
<argument type="service" id="cmf_routing.route_provider"/>
7071
<call method="setContainer"><argument type="service" id="service_container"/></call>
7172
<call method="addRouteEnhancer">
7273
<argument type="service" id="cmf_routing.enhancer.route_content"/>

0 commit comments

Comments
 (0)