Problem/Motivation

The API documentation for hook_pathauto_pattern_alter() is incorrect.

Proposed resolution

Update the documentation.

Remaining tasks

Review patch, commit.

User interface changes

None.

API changes

Nope.

Data model changes

Nada.

Suggested issue credit

Issue #2692205 by Dinesh18, ultimike, Spurlos, idebr, datvance, junkuncz: Update hook_pathauto_pattern_alter() documentation
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ultimike created an issue. See original summary.

LpSolit’s picture

Status: Active » Needs review
Berdir’s picture

Do we even invoke the hook at the moment? There's another issue about hooks not being invoked..

FeyP’s picture

Status: Needs review » Needs work

Thanks for your patch. I'll set it back to needs work. The updated example looks good at a first glance (didn't test it), but while you're at it, the DocBlock of the hook should also be updated. E.g. the $pattern parameter is no longer a string, but a \Drupal\pathauto\PathautoPatternInterface and there might as well be changes in the context variable.

> Do we even invoke the hook at the moment? There's another issue about hooks not being invoked..

It has been a few days, so it might have been fixed in the meantime. From looking at the source code, the hook is indeed invoked in \Drupal\pathauto\PathautoGenerator::createEntityAlias(), although there is a // @todo Is still hook still useful? directly above it.

Spurlos’s picture

I have updated the patch to mention PathautoPatternInterface usage.

gaurav.kapoor’s picture

Status: Needs work » Needs review
Dinesh18’s picture

Status: Needs review » Needs work

The Pathauto pattern entity which need its patter to be modified using.

spelling mistake written patter instead of pattern

Dinesh18’s picture

Status: Needs work » Needs review
FileSize
1.62 KB
590 bytes

Here is the updated patch and interdiff.txt

gettysburger’s picture

Comment #3 says "Do we even invoke the hook at the moment? There's another issue about hooks not being invoked.."

Is there a link to this issue? Tanks.

madhavvyas’s picture

#8 patch looks good to me.

Luke.Leber’s picture

On patch #8, if I'm not mistaken the type specifier in the @param annotation is generally the fully qualified class name with namespace.

idebr’s picture

  1. +++ b/pathauto.api.php
    @@ -93,9 +94,9 @@ function hook_pathauto_is_alias_reserved($alias, $source, $langcode) {
    + * @param PathautoPatternInterface $pattern
    + *   The Pathauto pattern entity which need its pattern to be modified using
    + *   setPattern() method.
    

    Updated to the fully qualified namespace to match Drupal coding standards.

  2. +++ b/pathauto.api.php
    @@ -107,10 +108,10 @@ function hook_pathauto_is_alias_reserved($alias, $source, $langcode) {
    +function hook_pathauto_pattern_alter(PathautoPatternInterface $pattern, array $context) {
    

    *.api.php files use fully qualified namespace arguments, see for example http://cgit.drupalcode.org/drupal/tree/core/modules/media/media.api.php

  3. Closed #2904456: Wrong documentation in hook_pathauto_pattern_alter as a duplicate and updated suggested issue credit in the issue summary.

Berdir credited datvance.

Berdir’s picture

Berdir credited junkuncz.

Berdir’s picture

  • Berdir committed 54155ac on 8.x-1.x authored by idebr
    Issue #2692205 by Dinesh18, idebr, ultimike, Spurlos, junkuncz, datvance...
Berdir’s picture

Status: Needs review » Fixed

Thanks, committed.

PS: issue credit these days is mostly about the issue metadata not the commit message. Just list the users to be added additionally, then I can add them .

Status: Fixed » Closed (fixed)

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