Problem/Motivation

It's my understanding that theme functions are deprecated, and that Twig templates should usually be used instead. Developers will expect to see a Twig template in general, and may not think to look for a theme function. Lastly, some themes don't even have a .theme file, which makes adds an extra step to overriding the markup produced by this module.

Proposed resolution

Instead of a theme function, use a Twig template.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brockfanning created an issue. See original summary.

Leon Kessler’s picture

Agreed, a twig template should be the way forward.

I realise this may break some sites already relying on the theme function, so perhaps this needs 8.3.x release (although the 8.2.x branch is still in beta).

Anyway it should be a pretty simple switch. Something like.....

Status: Needs review » Needs work

The last submitted patch, 2: 2903451-twig-template-instead-of-theme-function-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Leon Kessler’s picture

Needed to add a |raw into the twig file, as the spans are already rendered (so are getting escaped inside of twig). It's not very pretty, but can be fixed in child ticket: #2929460: Avoid rendering spans directly in the service

John Cook’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Drupal 9 compatibility
Related issues: +#3076535: Remove the usage of deprecated functions/methods/classes
FileSize
152.52 KB

I've had a look at the patch.

It applies well and only changes the the method how the markup is rendered.

The blocks are displayed as expected.
After patch:

As this issue is part of Drupal 9 compatibility, I've tagged as such.
Excerpt of compatibility report:

$ drush us-a sharethis
 [notice] Processing /var/www/drupalvm/drupal/web/modules/contrib/sharethis.
 12/12 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


================================================================================
ShareThis, --
Scanned on Tue, 05/26/2020 - 11:24

FILE: web/modules/contrib/sharethis/sharethis.module

STATUS         LINE                           MESSAGE                           
--------------------------------------------------------------------------------
Check manually 43   The module is defining "theme_sharethis_block" theme        
                    function. Theme functions are deprecated. For more info, see
                    https://www.drupal.org/node/2575445.                        
------------------------------------------------------------------------

The other issues are addressed in #3076535: Remove the usage of deprecated functions/methods/classes.

So I'm marking as RTBC.

naveenvalecha’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x-2.x

Status: Fixed » Closed (fixed)

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