Right know I let users create ads without the default language.
That must be fixed.
public function executeGetadsbygps(sfWebRequest $request)
{
//RESTFUL permits to use cookies to implement authentication (user / password)
- $parameters = $this->getRoute()->getParameters();
- $userId = $this->getUser()->getGuardUser()->getId();
$this->ads = array();
$this->ads = AdDescriptionTable::getInstance()->getAdsByGPSAndUserIdAndLanguageId($this->getRoute()->getParameters(),
//Return with the default language
$languageCode = sfConfig::get('app_default_language');
$languageId = LanguageTable::getInstance()->findOneByCode($languageCode)->getId();
- $ads[] = $this->findOneByAdIdAndLanguageId($adId, $languageId);
+ $ad = $this->findOneByAdIdAndLanguageId($adId, $languageId);
+ //This should never happen if every ad has at least the language by default.
+ //TODO: Do not let the users create ads without the default language.
+ if ($ad != null)
+ {
+ $ads[] = $ad;
+ }
}
}
return $ads;