public function getGetterCodeLocalizedfields($class)
{
$key = $this->getName();
$code = '/**' . "\n";
$code .= '* Get ' . str_replace(["/**", "*/", "//"], "", $this->getName()) . " - " . str_replace(["/**", "*/", "//"], "", $this->getTitle()) . "\n";
$code .= '* @return ' . $this->getPhpdocType() . "\n";
$code .= '*/' . "\n";
$code .= "public function get" . ucfirst($key) . ' ($language = null) {' . "\n";
$code .= "\t" . '$data = $this->getLocalizedfields()->getLocalizedValue("' . $key . '", $language);' . "\n";
if (!$class instanceof Object\Fieldcollection\Definition) {
// adds a hook preGetValue which can be defined in an extended class
$code .= "\t" . '$preValue = $this->preGetValue("' . $key . '");' . " \n";
$code .= "\t" . 'if($preValue !== null && !\\Pimcore::inAdmin()) { ' . "\n";
$code .= "\t\t" . 'return $preValue;' . "\n";
$code .= "\t" . '}' . "\n";
}
// we don't need to consider preGetData, because this is already managed directly by the localized fields within getLocalizedValue()
$code .= "\t return " . '$data' . ";\n";
$code .= "}\n\n";
return $code;
}