Consider adding a hook to Paragraphs::getSummary

Created on 10 April 2017, over 7 years ago
Updated 20 November 2023, 12 months ago

Follow-up to #2862083: [META] Improve paragraphs summary

Problem/Motivation

We currently support a few field types in getSummary. Modules that implement other field types could use a hook to handle their types.

Proposed resolution

Let's first see how much does current solution already cover and if we see that there are more use cases that we can't handle in Paragraphs, add the hook.

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

RTBC

Version

1.0

Component

Code

Created by

🇸🇮Slovenia primsi

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.

  • 🇬🇧United Kingdom andrew robinson

    I believe these patches fail in Drupal 10 sites with the error:

    Uncaught Error: Class "Symfony\Component\EventDispatcher\Event" not found in modules/contrib/paragraphs/src/Event/ParagraphSummaryAlterEvent.php:4

    According to vendor/symfony/event-dispatcher/CHANGELOG.md, in Symfony 5.x

    Based on this I think the use statement at the top of src/Event/ParagraphSummaryAlterEvent.php should be updated
    from
    use Symfony\Component\EventDispatcher\Event;
    to
    use Symfony\Contracts\EventDispatcher\Event;

    for sites that are based on Symfony 5 or above.

  • 🇩🇪Germany a.dmitriiev

    @vladigor@gmail.com In patch #38 this class is not used. It uses the class Drupal\Component\EventDispatcher\Event according to change record: https://www.drupal.org/node/3159012

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    180 pass
  • 🇬🇧United Kingdom andrew robinson

    Thanks @a.dmitriiev.
    I've switched over to patch #38 on my Drupal 10.1.0 site using Paragraphs 1.15.0.
    When I try to edit a page that contains paragraphs I get the following error:

    TypeError: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch(): Argument #1 ($event) must be of type object, string given, called in /app/docroot/modules/contrib/paragraphs/src/Entity/Paragraph.php on line 468 in Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (line 89 of core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php).
    

    It appears that in Drupal 10.1 the event_dispatcher service uses the dispatch function from ContainerAwareEventDispatcher.php, which expects $event as the first parameter.
    Ref. https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Even...

    I've attached an updated version of patch #38 that switches around the parameters in the two calls to the dispatch function.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    159 pass, 12 fail
  • Status changed to Needs review over 1 year ago
  • 🇧🇪Belgium LRoels Ghent

    Changing the status to needs review for now. Seems wrong to keep it on RTBC.

  • 🇬🇧United Kingdom LiamPower

    #42 is working for me with Drupal 10.1.5 and Paragraphs 8.x-1.16

  • Status changed to RTBC about 1 year ago
  • 🇩🇪Germany a.dmitriiev

    #42 is working for me as well for Drupal 10

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 12 months ago
    Composer require-dev failure
  • 🇺🇸United States gmercer

    Re-rolled #42 patch to check for empty of summary[$type] on appendTextToSummary() and prependTextToSummary() in src/Event/ParagraphSummaryAlterEvent.php

Production build 0.71.5 2024