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

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

Creates setter code which is used for generation of php file for localized fields in classes using this data type
public getSetterCodeLocalizedfields ( $class ) : string
$class
Результат string
    public function getSetterCodeLocalizedfields($class)
    {
        $key = $this->getName();
        if ($class instanceof Object\Fieldcollection\Definition) {
            $classname = ucfirst($class->getKey());
        } else {
            $classname = $class->getName();
        }
        $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($classname) . "\n";
        $code .= '*/' . "\n";
        $code .= "public function set" . ucfirst($key) . " (" . '$' . $key . ', $language = null) {' . "\n";
        $code .= "\t" . '$this->getLocalizedfields()->setLocalizedValue("' . $key . '", $' . $key . ', $language)' . ";\n";
        $code .= "\t" . 'return $this;' . "\n";
        $code .= "}\n\n";
        return $code;
    }