Problem/Motivation

Drupal 12 will drop hook_module_implements_alter

Steps to reproduce

Proposed resolution

Convert hooks to OOP

  1. Convert metatag_page_attachments_alter to OOP either by hand or with Rector https://www.drupal.org/node/3442349
  2. Mark it as last https://www.drupal.org/node/3493962
  3. For bonus points mark HMIA with LegacyModuleImplementsAlter
public function __construct(protected RouteMatchInterface $routeMatch) {
}
#[Hook('page_attachments_alter', order: Order::Last)]
public function PageAttachmentsAlter(array &$attachments) {
  if ($this->routeMatch->getRouteName() == 'entity.taxonomy_term.canonical' && ($term = $this->routeMatch->getParameter('taxonomy_term')) && $term instanceof TermInterface) {
    _metatag_remove_duplicate_entity_tags($attachments);
  }
}

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork metatag-3574819

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

ghost of drupal past created an issue. See original summary.

nicxvan made their first commit to this issue’s fork.

damienmckenna’s picture

damienmckenna’s picture

Status: Active » Postponed

Lets wait for #3398796: Add PHP attributes for all plugins to be finished first.

nicxvan’s picture

Title: Minimal necessary to support Drupal 12 » Metatag: Convert hooks to OOP
nicxvan’s picture

I will still push up an initial version

nicxvan’s picture

Status: Postponed » Needs review

Not sure we need to postpone this, it won't conflict and it's green.

nicxvan’s picture

Issue summary: View changes
damienmckenna’s picture

Status: Needs review » Needs work

Thank you chx and nic. The MR needs to be updated from some changes I made in 2.2.x to make the tests pass again 11.3.

nicxvan’s picture

Yeah I knew that would conflict actually, I did that in the widget issue too, I reverted the change, I'll keep an eye on tests.

nicxvan’s picture

Status: Needs work » Needs review
damienmckenna’s picture

Status: Needs review » Needs work

The last remaining item is confirming the info files and composer.json have the correct minimum core versions noted in order for this to work, we don't want people accidentally downloading it on an older version of core that it won't work with. Any suggestions?

damienmckenna’s picture

For clarification, the primary OOP hooks changes went into 10.2 and 11.2 per https://www.drupal.org/node/3395575.

The question is whether any of the specific hooks only changed in 10.3 or other branches.

nicxvan’s picture

This should be fully compatible back to at least 10.1.

The only non BC hook changes have really been themes.

nicxvan’s picture

I'll review this real quick

nicxvan’s picture

Ok I pushed that up.
The root module already set the minimum 10.3
I updated all submodules to 10.1, I'm happy to bump that to 10.3 for consistency if you want.

nicxvan’s picture

Status: Needs work » Needs review
damienmckenna’s picture

Thanks for reviewing that. Yes, lets take the time to update the info files so they're consistent.

Have you tested on the early 11.x branches?

nicxvan’s picture

I bumped the version so they are all consistent.

I installed drupal 10.3.1
I installed every module except page variant since I don't have a dependency.

I then added it to article and updated several fields and then looked at the output and they were all printed as expected.

I also edited the configuration and that looked correct and checked there was an extended permission for the MS thing.

damienmckenna’s picture

Status: Needs review » Fixed
Parent issue: » #3548158: Plan for Metatag 2.2.1

Committed! Thank you both, especially to nicxvan for all the detailed work getting it all sorted out so nicely!

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.

damienmckenna’s picture

Issue tags: +OOP Hooks