//Otherwise return with the default language
$languageCode = sfConfig::get('app_default_language');
- $languageId = LanguageTable::getInstance()->findByCode($languageCode);
+ $languageId = LanguageTable::getInstance()->findOneByCode($languageCode)->getId();
foreach ($adDescriptions as $adDescription)
{
if ($adDescription->getLanguageId() == $languageId)
*
* @package mobiads
* @subpackage model
- * @author Your name here
- * @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
+ * @author Gustavo Martin Morcuende
+ * @version
*/
class Company extends BaseCompany
{
+
+ /**
+ * Returns the string representation of this object.
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ $languageId = sfContext::getInstance()->getUser()->getGuardUser()->getLanguage()->getId();
+
+ //Check if there is description with the user's language
+ $companyDescriptions = CompanyDescriptionTable::getInstance()->findByCompanyId($this->getId());
+ foreach ($companyDescriptions as $companyDescription)
+ {
+ if ($companyDescription->getLanguageId() == $languageId)
+ {
+ //We found it!!!
+ return (string) $companyDescription->getCompanyName();
+ }
+ }
+
+ //Otherwise return with the default language
+ $languageCode = sfConfig::get('app_default_language');
+ $languageId = LanguageTable::getInstance()->findOneByCode($languageCode)->getId();
+ foreach ($companyDescriptions as $companyDescription)
+ {
+ if ($companyDescription->getLanguageId() == $languageId)
+ {
+ //We found the default name description!!!
+ return (string) $companyDescription->getCompanyName();
+ }
+ }
+
+ //Finally, if nothing was found, return nice error message.
+ return (string) "Company without default language";
+ }
}
//Otherwise return with the default language
$languageCode = sfConfig::get('app_default_language');
- $languageId = LanguageTable::getInstance()->findByCode($languageCode);
+ $languageId = LanguageTable::getInstance()->findOneByCode($languageCode)->getId();
foreach ($generalCategoryDescriptions as $generalCategoryDescription)
{
if ($generalCategoryDescription->getLanguageId() == $languageId)