public function getTableName()
{
if (empty($this->tableName)) {
// default
$this->tableName = "object_" . $this->model->getClassId();
if (!$this->model->getIgnoreLocalizedFields()) {
$language = null;
// check for a localized field and if they should be used for this list
if (property_exists("\\Pimcore\\Model\\Object\\" . ucfirst($this->model->getClassName()), "localizedfields")) {
if ($this->model->getLocale()) {
if (Tool::isValidLanguage((string) $this->model->getLocale())) {
$language = (string) $this->model->getLocale();
}
}
if (!$language && \Zend_Registry::isRegistered("Zend_Locale")) {
$locale = \Zend_Registry::get("Zend_Locale");
if (Tool::isValidLanguage((string) $locale)) {
$language = (string) $locale;
}
}
if (!$language) {
$language = Tool::getDefaultLanguage();
}
if (!$language) {
throw new \Exception("No valid language/locale set. Use \$list->setLocale() to add a language to the listing, or register a global locale");
}
$this->tableName = "object_localized_" . $this->model->getClassId() . "_" . $language;
}
}
}
return $this->tableName;
}