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

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

The return value is a list of data definitions containing the following attributes: - "field" => the name of the object field - "key" => a unique key identifying the data element - "type" => the type of the data component - "value" => the value used as preview - "data" => the actual data which is then sent back again by the editor. Note that the data is opaque and will not be touched by the editor in any way. - "disabled" => whether the data element can be edited or not - "title" => pretty name describing the data element
public getDiffDataForEditMode ( mixed $data, null | AbstractObject $object = null, mixed $params = [] ) : null | array
$data mixed
$object null | Pimcore\Model\Object\AbstractObject
$params mixed
Результат null | array
    public function getDiffDataForEditMode($data, $object = null, $params = [])
    {
        $diffdata = [];
        $diffdata["data"] = $this->getDataForEditmode($data, $object, $params);
        $diffdata["disabled"] = !$this->isDiffChangeAllowed($object);
        $diffdata["field"] = $this->getName();
        $diffdata["key"] = $this->getName();
        $diffdata["type"] = $this->fieldtype;
        if (method_exists($this, "getDiffVersionPreview")) {
            $value = $this->getDiffVersionPreview($data, $object, $params);
        } else {
            $value = $this->getVersionPreview($data, $object, $params);
        }
        $diffdata["title"] = !empty($this->title) ? $this->title : $this->name;
        $diffdata["value"] = $value;
        $result = [];
        $result[] = $diffdata;
        return $result;
    }

Usage Example

 /** See parent class.
  * @param mixed $data
  * @param null $object
  * @return array|null
  */
 public function getDiffDataForEditMode($data, $object = null)
 {
     $defaultData = parent::getDiffDataForEditMode($data, $object);
     $html = $defaultData[0]["value"];
     $value = array();
     $value["html"] = $html;
     $value["type"] = "html";
     $defaultData[0]["value"] = $value;
     return $defaultData;
 }