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.
Comment | File | Size | Author |
---|---|---|---|
#4 | paragraphs_frontend_ui-getType-undefined-3067599-4.patch | 1.27 KB | VitalyM |
Comments
Comment #2
VitalyM CreditAttribution: VitalyM at FFW commentedWe 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.
Comment #3
VitalyM CreditAttribution: VitalyM at FFW commentedComment #4
VitalyM CreditAttribution: VitalyM at FFW commentedFixed typo in the patch file.
Comment #5
Jorge Navarro CreditAttribution: Jorge Navarro commentedThe patch works perfect! Thank you!
Comment #6
sergiuteaca CreditAttribution: sergiuteaca at FFW commented+1 to RTBC
Comment #7
svdhout CreditAttribution: svdhout at Calibrate commentedI'm working on a 8.2 branch that uses Paragraphs Library instead of Paragraph sets.
Added the patch there.
Comment #8
svdhout CreditAttribution: svdhout at Calibrate commentedComment #10
chekka.de CreditAttribution: chekka.de commentedYour 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'.
Comment #11
sergiuteaca CreditAttribution: sergiuteaca at FFW commented@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.