Browse files

Fixed the case where the translator is null

  • Loading branch information...
1 parent b959104 commit b721076ef0c400ae10ee65c8a09d7fc3c3c31f08 @stof committed Jul 31, 2011
Showing with 8 additions and 6 deletions.
  1. +8 −6 Routing/Router.php
View
14 Routing/Router.php
@@ -62,10 +62,12 @@ public function generate($name, $parameters = array(), $absolute = false)
}
if (isset($parameters['translate'])) {
- foreach (array($parameters['translate']) as $translateAttribute) {
- $parameters[$translateAttribute] = $this->translator->reverseTranslate(
- $name, $locale, $translateAttribute, $parameters[$translateAttribute]
- );
+ if (null !== $this->translator) {
+ foreach ((array) $parameters['translate'] as $translateAttribute) {
+ $parameters[$translateAttribute] = $this->translator->reverseTranslate(
+ $name, $locale, $translateAttribute, $parameters[$translateAttribute]
+ );
+ }
}
unset($parameters['translate']);
}
@@ -97,8 +99,8 @@ public function match($url)
$match['_route'] = $route[1];
// now also check if we want to translate parameters:
- if (isset($match['_translate'])) {
- foreach ((array)$match['_translate'] as $attribute) {
+ if (null !== $this->translator && isset($match['_translate'])) {
+ foreach ((array) $match['_translate'] as $attribute) {
$match[$attribute] = $this->translator->translate(
$match['_route'], $match['_locale'], $attribute, $match[$attribute]
);

0 comments on commit b721076

Please sign in to comment.