public function getChangedFields(array $contentType)
    {
        $changedFields = [];

        if (empty($this->diff)) {
            return $changedFields;
        }

        // Get the ContentType that we're dealing with
        $fields = $contentType['fields'];

        $hash = [
            'html'        => 'fieldText',
            'markdown'    => 'fieldText',
            'textarea'    => 'fieldText',
            'filelist'    => 'fieldList',
            'imagelist'   => 'fieldList',
            'geolocation' => 'fieldGeolocation',
            'image'       => 'fieldImage',
            'embed'       => 'fieldVideo',
            'select'      => 'fieldSelect',
            'video'       => 'fieldVideo',
        ];

        foreach ($this->diff as $key => $value) {
            if (!isset($fields[$key])) {
                continue;
            }

            $type = $fields[$key]['type'];
            $changedFields[$key] = [
                'type'   => $type,
                'label'  => empty($fields[$key]['label']) ? $key : $fields[$key]['label'],
                'before' => [
                    'raw'    => $value[0],
                    'render' => $value[0],
                ],
                'after'  => [
                    'raw'    => $value[1],
                    'render' => $value[1],
                ],
            ];

            /** @var string $type */
            $type = $fields[$key]['type'];
            if (isset($hash[$type])) {
                $func = $hash[$type];
                $changedFields[$key] = array_merge($changedFields[$key], $this->{$func}($key, $value, $fields));
            }
        }

        return $changedFields;
    }
public function getChangedFields(array $contentType)
    {
        $changedFields = [];

        if (empty($this->diff)) {
            return $changedFields;
        }

        // Get the ContentType that we're dealing with
        $fields = $contentType['fields'];

        $hash = [
            'html'        => 'fieldText',
            'markdown'    => 'fieldText',
            'textarea'    => 'fieldText',
            'filelist'    => 'fieldList',
            'imagelist'   => 'fieldList',
            'geolocation' => 'fieldGeolocation',
            'image'       => 'fieldImage',
            'embed'       => 'fieldVideo',
            'select'      => 'fieldSelect',
            'video'       => 'fieldVideo',
        ];

        foreach ($this->diff as $key => $value) {
            if (!isset($fields[$key])) {
                continue;
            }

            $type = $fields[$key]['type'];
            $changedFields[$key] = [
                'type'   => $type,
                'label'  => empty($fields[$key]['label']) ? $key : $fields[$key]['label'],
                'before' => [
                    'raw'    => $value[0],
                    'render' => $value[0],
                ],
                'after'  => [
                    'raw'    => $value[1],
                    'render' => $value[1],
                ],
            ];

            /** @var string $type */
            $type = $fields[$key]['type'];
            if (isset($hash[$type])) {
                $func = $hash[$type];
                $changedFields[$key] = array_merge($changedFields[$key], $this->{$func}($key, $value, $fields));
            }
        }

        return $changedFields;
    }
public function getChangedFields ( array $ contentType ) { $ changedFields = [ ] ; if ( empty ( $ this -> diff ) ) { return $ changedFields ; } // Get the ContentType that we're dealing with $ fields = $ contentType [ 'fields' ] ; $ hash = [ 'html' => 'fieldText' , 'markdown' => 'fieldText' , 'textarea' => 'fieldText' , 'filelist' => 'fieldList' , 'imagelist' => 'fieldList' , 'geolocation' => 'fieldGeolocation' , 'image' => 'fieldImage' , 'embed' => 'fieldVideo' , 'select' => 'fieldSelect' , 'video' => 'fieldVideo' , ] ; foreach ( $ this -> diff as $ key => $ value ) { if ( ! isset ( $ fields [ $ key ] ) ) { continue ; } $ type = $ fields [ $ key ] [ 'type' ] ; $ changedFields [ $ key ] = [ 'type' => $ type , 'label' => empty ( $ fields [ $ key ] [ 'label' ] ) ? $ key : $ fields [ $ key ] [ 'label' ] , 'before' => [ 'raw' => $ value [ 0 ] , 'render' => $ value [ 0 ] , ] , 'after' => [ 'raw' => $ value [ 1 ] , 'render' => $ value [ 1 ] , ] , ] ; /** @var string $type */ $ type = $ fields [ $ key ] [ 'type' ] ; if ( isset ( $ hash [ $ type ] ) ) { $ func = $ hash [ $ type ] ; $ changedFields [ $ key ] = array_merge ( $ changedFields [ $ key ] , $ this -> { $ func } ( $ key , $ value , $ fields ) ) ; } } return $ changedFields ; }
Get changed fields.

@param array $contentType

@return array
Get changed fields .