Pimcore\Model\Object\ClassDefinition\Data::getGetterCodeObjectbrick PHP Метод

getGetterCodeObjectbrick() публичный Метод

Creates getter code which is used for generation of php file for object brick classes using this data type
public getGetterCodeObjectbrick ( $brickClass ) : string
$brickClass
Результат string
    public function getGetterCodeObjectbrick($brickClass)
    {
        $key = $this->getName();
        $code = "";
        $code .= '/**' . "\n";
        $code .= '* Set ' . str_replace(["/**", "*/", "//"], "", $this->getName()) . " - " . str_replace(["/**", "*/", "//"], "", $this->getTitle()) . "\n";
        $code .= '* @return ' . $this->getPhpdocType() . "\n";
        $code .= '*/' . "\n";
        $code .= "public function get" . ucfirst($key) . " () {\n";
        if (method_exists($this, "preGetData")) {
            $code .= "\t" . '$data = $this->getDefinition()->getFieldDefinition("' . $key . '")->preGetData($this);' . "\n";
        } else {
            $code .= "\t" . '$data = $this->' . $key . ";\n";
        }
        $code .= "\t" . 'if(\\Pimcore\\Model\\Object::doGetInheritedValues($this->getObject()) && $this->getDefinition()->getFieldDefinition("' . $key . '")->isEmpty($data)) {' . "\n";
        $code .= "\t\t" . 'return $this->getValueFromParent("' . $key . '");' . "\n";
        $code .= "\t" . '}' . "\n";
        $code .= "\t return " . '$data' . ";\n";
        $code .= "}\n\n";
        return $code;
    }