Skip to content

Commit 0c8e317

Browse files
committed
ensure that the LocaleListner handles any Route model instance (including redirects)
1 parent ac975ff commit 0c8e317

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Doctrine/Phpcr/LocaleListener.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\ODM\PHPCR\DocumentManager;
1515
use Doctrine\ODM\PHPCR\Event\MoveEventArgs;
1616
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
17+
use Symfony\Cmf\Bundle\RoutingBundle\Model\Route as ModelRoute;
1718

1819
/**
1920
* Doctrine PHPCR-ODM listener to update the locale on routes based on the URL.
@@ -118,7 +119,7 @@ public function setUpdateAvailableTranslations($update)
118119
public function postLoad(LifecycleEventArgs $args)
119120
{
120121
$doc = $args->getObject();
121-
if (! $doc instanceof Route) {
122+
if (! $doc instanceof ModelRoute) {
122123
return;
123124
}
124125
$this->updateLocale($doc, $doc->getId(), $args->getObjectManager());
@@ -132,7 +133,7 @@ public function postLoad(LifecycleEventArgs $args)
132133
public function postPersist(LifecycleEventArgs $args)
133134
{
134135
$doc = $args->getObject();
135-
if (! $doc instanceof Route) {
136+
if (! $doc instanceof ModelRoute) {
136137
return;
137138
}
138139
$this->updateLocale($doc, $doc->getId(), $args->getObjectManager());
@@ -146,7 +147,7 @@ public function postPersist(LifecycleEventArgs $args)
146147
public function postMove(MoveEventArgs $args)
147148
{
148149
$doc = $args->getObject();
149-
if (! $doc instanceof Route) {
150+
if (! $doc instanceof ModelRoute) {
150151
return;
151152
}
152153
$this->updateLocale($doc, $args->getTargetPath(), $args->getObjectManager(), true);
@@ -164,7 +165,7 @@ protected function getPrefixes()
164165
* Update the locale of a route if $id starts with the prefix and has a
165166
* valid locale right after.
166167
*
167-
* @param Route $doc The route object
168+
* @param ModelRoute $doc The route object
168169
* @param string $id The id (in move case, this is not the current
169170
* id of $route).
170171
* @param DocumentManager $dm The document manager to get locales from if
@@ -173,7 +174,7 @@ protected function getPrefixes()
173174
* @param boolean $force Whether to update the locale even if the
174175
* route already has a locale.
175176
*/
176-
protected function updateLocale(Route $doc, $id, DocumentManager $dm, $force = false)
177+
protected function updateLocale(ModelRoute $doc, $id, DocumentManager $dm, $force = false)
177178
{
178179
$matches = array();
179180

0 commit comments

Comments
 (0)