I've found that if you have a paragraph field in a block, it doesn't work and there is an error:

Error: Call to undefined method Drupal\block_content\Entity\BlockContent::getType() in Drupal\paragraphs_frontend_ui\Controller\ParagraphsFrontendUIController->getParentData() (line 146 of /var/www/html/paho/modules/contrib/paragraphs_frontend_ui/src/Controller/ParagraphsFrontendUIController.php) #0 /var/www/html/paho/modules/contrib/paragraphs_frontend_ui/src/Controller/ParagraphsFrontendUIController.php(108)

The problematic line is:

  private function getParentData($paragraph) {
    $parent = $paragraph->getParentEntity()->getTranslation($this->langcode());
    return [
      'parent' => $parent,
      'parent_type' => $parent->getEntityTypeId(),
      //<strong>'parent_bundle' => $parent->getType(),</strong>
      'parent_entity_id' => $parent->id(),
      'parent_field_name' => $paragraph->get('parent_field_name')->getValue()[0]['value'],
    ];
  }

And commenting it get the error out but I don't know the implications.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jorge Navarro created an issue. See original summary.

VitalyM’s picture

We have the same issues but with the paragraphs attached to menu entities. The issue can be fixed by changing $parent->getType() with $parent->bundle(). It seems that the author assumed paragraph usage on nodes only. So, there can be other typos like this.
Attached the patch as well.

VitalyM’s picture

Status: Active » Needs review
VitalyM’s picture

Fixed typo in the patch file.

Jorge Navarro’s picture

Status: Needs review » Reviewed & tested by the community

The patch works perfect! Thank you!

sergiuteaca’s picture

+1 to RTBC

svdhout’s picture

I'm working on a 8.2 branch that uses Paragraphs Library instead of Paragraph sets.
Added the patch there.

svdhout’s picture

Version: 8.x-1.x-dev » 8.x-2.0-alpha1
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

chekka.de’s picture

Your patch refers to a file '/src/Form/ParagraphsFrontendUIAddSet.php' but the is no such file in your package.
I just can find a file called 'ParagraphsFrontendUIAddBelow.php'.

sergiuteaca’s picture

@chekka.de There were paragraph_set sub-module in the 1.x version.
Since 2.x version Paragraph Frontend UI uses the paragraph_library (a sub-module from paragraphs)
The patch was made for 1.x and then adapted for 2.x by the maintainer.