Right now this is a difficult module to work with outside of the Drupal GUI use case. I found I had to duplicate a lot of code from the .module file just to get the list of tags for a node (including defaults) into an API module, for example.

Attached a patch that adds default handling into the MetatagManager class, so you can get default tags for an entity, or get the complete tags with defaults for an entity. Also used it a bit in the .module file to show how some refactoring might work. I don't particularly think this NEEDS urgent refactoring in the rest of the module, but it makes a big difference for Dx to have the methods there.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ohthehugemanatee created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, metatag-add-defaults-handling-to-manager.patch, failed testing.

ohthehugemanatee’s picture

Whoops, seems I caught some recent dev branch changes in that patch. Trying again...

Status: Needs review » Needs work

The last submitted patch, 3: 2853515-metatag-add-defaults-handling-to-manager-1.patch, failed testing.

ohthehugemanatee’s picture

Minor fix in the .module example implementation

Status: Needs review » Needs work

The last submitted patch, 5: 2853515-metatag-add-defaults-handling-to-manager-2.patch, failed testing.

ohthehugemanatee’s picture

wow, didn't think through all the different cases the .module has to handle. Simplifying this patch to only provide the methods for developers in MetatagManager. Refactoring is a separate issue.

DamienMcKenna’s picture

This looks like a great idea, and might help with some other things (JSON output, etc).

I need to look over the tests to see how they could be possibly expanded to make sure this works as intended.

DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Needs review » Fixed
Parent issue: » #2563615: Plan for Metatag 8.x-1.1 release

Refactoring + tests work = happy Damien :)

Thanks!

Status: Fixed » Closed (fixed)

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