public function getGetterCode($class)
{
$key = $this->getName();
$code = "";
$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) . " () {\n";
// 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";
if (method_exists($this, "preGetData")) {
$code .= "\t" . '$data = $this->getClass()->getFieldDefinition("' . $key . '")->preGetData($this);' . "\n";
} else {
$code .= "\t" . '$data = $this->' . $key . ";\n";
}
// insert this line if inheritance from parent objects is allowed
if ($class->getAllowInherit()) {
$code .= "\t" . 'if(\\Pimcore\\Model\\Object::doGetInheritedValues() && $this->getClass()->getFieldDefinition("' . $key . '")->isEmpty($data)) {' . "\n";
$code .= "\t\t" . 'return $this->getValueFromParent("' . $key . '");' . "\n";
$code .= "\t" . '}' . "\n";
}
$code .= "\treturn " . '$data' . ";\n";
$code .= "}\n\n";
return $code;
}