Problem/Motivation

When using a view that has block_content as entity type id, the following warning is generated.
Warning: Undefined array key "#theme" in Drupal\swiper_formatter\Plugin\views\style\SwiperFormatterStyle->render() (line 234 of modules/contrib/swiper_formatter/src/Plugin/views/style/SwiperFormatterStyle.php).

Steps to reproduce

1. Navigate to /admin/structure/block-content, and create a Block Type if you don't have any.
2. Create a few block contents.
3. Create a view that shows "Content Block".
4. Apply the swiper formatter style plugin.
5. If the view is a block, place it somewhere. I used a block in layout builder.
6. Navigate to the page and observe the warning.

Proposed resolution

When debugging this, I noticed that the block content had the key '#entity_type'. So, my proposition is to add an extra case in the if statement that checks for the entity to have it work for this case. I compared with nodes, and indeed nodes don't have it, but block_content has it.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bbu23 created an issue. See original summary.

bbu23’s picture

Assigned: bbu23 » Unassigned
Issue summary: View changes
Status: Active » Needs review
chrisolof’s picture

I just ran into this bug while attempting to display ECK entities in a views block using the swiper formatter views plugin. The changes in MR 2 fix the issue for me. Thanks @bbu23!

Attached is an immutable patch snapshot of MR 2, as it stands today.

  • nk_ committed 59bda303 on 1.0.x
    Issue #3403505 by bbu23, chrisolof: Warning: Undefined array key "#theme...
nk_’s picture

Version: 1.0.x-dev » 1.0.7
Status: Needs review » Fixed

Thank you all! It was finally committed in the new release, the last one supporting Drupal 8.8 and 9. A brand new branch 2.0.x with quite some new features is there and recommended for a future use.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nk_’s picture

bbu23’s picture

StatusFileSize
new324.68 KB

It seems that the tag 1.0.7 was created prior to the commit that fixes this in 1.0.x.
Not sure if you're aware of this, so the change + another one are not included in 1.0.7

commit log 1.0.x

bbu23’s picture

Temporary solution for 1.0.7 is applying the commit patch (if anyone needs it): https://git.drupalcode.org/project/swiper_formatter/-/commit/59bda303dea...