Problem/Motivation

buildButtonsAddMode() assumes that the config entity for the paragraph type is paragraphs_type, however isApplicable() returns $paragraph_type->entityClassImplements(ParagraphInterface::class); allowing it to be used on other entity types that also implement ParagraphInterface

Proposed resolution

Loading the target_type from the field definition and use $target_type->getBundleEntityType() to get the config entity.

Remaining tasks

Handle entities that implement ParagraphInterface but don't have bundles

User interface changes

None

API changes

None

Data model changes

Release notes snippet

Issue fork paragraphs-3122821

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

dwkitchen created an issue. See original summary.

dwkitchen’s picture

StatusFileSize
new1.65 KB

Patch attached

berdir’s picture

Status: Active » Needs work

The storage is used to access the icon information. If there's no bundle or a different one then this is likely going to fail on the getIconUrl() call, this doesn't really seem to help much? There's also at least one other call: $paragraphs_entity->type->entity->getIconUrl()

Maybe that feature should be specific to the actual paragraph entity type? Could wrap it in a method and only bother to do that if the entity type matches?

dwkitchen’s picture

I think adding this in before the try would throw the correct error if the entity doesn't implement the PargraphInterface - which requires the getIconUrl() function

if (!$target_type->entityClassImplements(ParagraphInterface::class)) {
  throw new EntityStorageException('Entity does not implement ParagraphInterface');
}

However, the isApplicable() of the widget shouldn't allow the widget to be used on an entity that doesn't implement getIconUrl()

Let me know what you think and I will update the patch.

dwkitchen’s picture

Status: Needs work » Needs review
StatusFileSize
new2.04 KB
new2.75 KB

Added the entityClassImpliments check as proposed.

socialnicheguru’s picture

Status: Needs review » Needs work

no longer apply to dev version of paragraphs

dwkitchen’s picture

Status: Needs work » Needs review

I have opened a new merge request.