Need to access protected property "parent" in CshsOption class

Created on 2 June 2022, about 2 years ago
Updated 14 November 2023, 8 months ago

Problem/Motivation

I'm currently using the cshs in a view where the options need to be filtered programmatically to subtract the ones a specific user hasn't access to. It used to work in version 1.3 of the module when the options were an array instead of an object.

Steps to reproduce

Iterating through the form element returns an error when trying to access the parent of an option.

foreach($filter_identifier['#options'] as $zone_id => $object){
    dpm($option->parent);
// if the option key or its parent is not in the user's allowed zones, remove the option from the cshs form element.
}

Error: Cannot access protected property Drupal\cshs\Component\CshsOption::$parent

Proposed resolution

What would be the impact of making this property public?
Is there another way for me the filter the options on the fly from a hook_form_views_exposed_form_alter?

πŸ’¬ Support request
Status

Active

Version

3.6

Component

Code

Created by

πŸ‡«πŸ‡·France lizuka

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024