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

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

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