Use thirdPartySetting for component styles

Created on 22 February 2023, almost 2 years ago

Problem/Motivation

I happen to have the need to get the component styles in my own event subscriber (SECTION_COMPONENT_BUILD_RENDER_ARRAY). I'm getting the following PHPCS error using $event->getComponent()->get('layout_builder_styles_style'):

Call to deprecated method get() of class Drupal\layout_builder\SectionComponent: in drupal:9.1.0 and is removed from drupal:10.0.0. Additional component properties should be gotten via ::setThirdPartySetting().

Instead, I think I should be using $event->getComponent()->getThirdPartySetting('layout_builder_styles, 'style'), but the styles are not currently stored in third party setting. Instead they are stored in additional, so there is no way to access them from the previous call.

Steps to reproduce

I had to write custom code to encounter this, so reproducing would probably require something like the above, although I can also just see a warning about it in my IDE, so maybe that is sufficient?

Proposed resolution

Update the logic to move storage of styles in thirdPartySetting for blocks.

Remaining tasks

Update submit handler for blocks to store styles in thirdPartySetting.
Write an update hook to move existing style instances from additional to thirdPartySetting?

User interface changes

None

API changes

None, I think

Data model changes

Moving style storage for blocks from additional to thirdPartySetting

πŸ“Œ Task
Status

Postponed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States pyrello

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024