sulu / SuluArticleBundle

Bundle for managing localized content-rich entities like blog-posts in the Sulu content management system
MIT License
57 stars 78 forks source link

Extensions are not updated inside the preview #675

Closed Olivier127 closed 6 months ago

Olivier127 commented 6 months ago
Q A
Bug? yes
New Feature? no
SuluArticleBundle Version 2.5.3
Sulu Version 2.5.15

Actual Behavior

Identical to the #7348 of sulu

Expected Behavior

The extensions must be refresh

Steps to Reproduce

Identical to the #7348 of sulu

Possible Solutions

Change this code inside ArticleObjectProvider

    public function setValues($object, $locale, array $data)
    {
        $propertyAccess = PropertyAccess::createPropertyAccessorBuilder()
            ->enableMagicCall()
            ->getPropertyAccessor();

        $structure = $object->getStructure();
        foreach ($data as $property => $value) {
            try {
                $propertyAccess->setValue($structure, $property, $value);
            } catch (\InvalidArgumentException $e) {
                // @ignoreException
                //ignore not existing properties
            }
        }
    }

to this code

    public function setValues($object, $locale, array $data)
    {
        $propertyAccess = PropertyAccess::createPropertyAccessorBuilder()
            ->enableMagicCall()
            ->getPropertyAccessor();

        $structure = $object->getStructure();
        foreach ($data as $property => $value) {
            try {
                if ('ext' === $property) {
                    $object->setExtensionsData(new ExtensionContainer($value));
                    continue;
                }

                $propertyAccess->setValue($structure, $property, $value);
            } catch (\InvalidArgumentException $e) {
                //ignore not existing properties
            }
        }
    }