Problem/Motivation

This module implements a lot of hooks but does not yet make use of D11's hook classes. Should be transitioning to the hook class model: https://www.drupal.org/node/3442349

Issue fork mposse-3555465

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

megakeegman created an issue. See original summary.

megakeegman’s picture

Status: Active » Needs review
megakeegman’s picture

Status: Needs review » Needs work
The website encountered an unexpected error. Try again later.

Error: Class "Drupal\mposse\Hook\MposseHooks" not found in Drupal\Component\DependencyInjection\Container->createService() (line 261 of core/lib/Drupal/Component/DependencyInjection/Container.php).

Drupal\Component\DependencyInjection\Container->get() (Line: 197)
Drupal::service() (Line: 70)
mposse_form_node_type_form_alter() (Line: 552)
...

The important things to look at are the legacy hook implementations in the mposse.module file (in particular the service call on line 70, but I imagine they should all have the same problem) and the mposse.services.ymlAm I missing something? I have done several ddev poweroffs and cache rebuilds and Drupal can't seem to find this class

megakeegman’s picture

We should also be able to transition from module_implements_alter for manipulating the weight of form alters and just use the hook weights attribute directly: https://www.drupal.org/node/3493962

I'm not sure whether I can implement those attributes while also implementing legacy hooks for backwards compatibility?

I presume we should wait until restricting this module D11.2+

megakeegman’s picture

FWIW I tried changing the service name to 'mposse.hooks' and calling the service with that name, and the error didn't change at all

megakeegman’s picture

Status: Needs work » Needs review

Resolved the fatal error. I just had the hook class file in the wrong location. Ready for more thorough testing.

megakeegman’s picture

Tested on Drupal 10.5, everything seems to be working. Still need to test on 11.0 and 11.2+

Modules implementing mposse social platform plugin will need to order their node edit form alter hooks to run after mposse (post 11.2)

Those hook function attributes should be updated to look like:

#[Hook('some_hook', 
  order: new OrderAfter(
    classesAndMethods: [
      [Foo::class, 'someMethod'],
      [Bar::class, 'someOtherMethod'],
    ]
  )
)]

per https://www.drupal.org/node/3493962

megakeegman’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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