Pathauto behavior should be exportable adding a "pathauto" data to the exposed path.

Doing so using a field enhancer on JSON:API extras should be ok.

But after testing with hardcoded values, it seems that the value are taken into account only when the entity is created not updated.

Case:

With Pathauto patterns (similar or different) on client and server websites.

If on the server, an entity has a path and is marked as path automatically generated, when imported on a client website, the boolean pathauto is still on autogenerated and it is the pattern of the client site that is used.

If on the server, an entity has a path and is marked as path NOT automatically generated, when imported on a client website, the boolean pathauto is still on NOT autogenerated and it is the pattern (path generated) on the server site that is used.

This needs to be investigated. Maybe the problem is in pathauto. But it should be possible to update the path and to update if the path should be controlled by the client or the server website.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Grimreaper created an issue. See original summary.

Grimreaper’s picture

The update code of an already imported entity is:

           foreach ($entity_data['attributes'] as $field_name => $value) {
              $field_name = $resource_type->getInternalName($field_name);
              $existing_translation->set(
                $field_name,
                $entity->get($field_name)->getValue()
              );
            }

            $translation = $entity->toArray();
            $existing_entity->addTranslation($data_langcode, $translation);
            $existing_entity->save();
            $existing_translation = $existing_entity->getTranslation($data_langcode);

Maybe due to that, as the path is a calculated value, the addition of the "pathauto" data has no impact.

Grimreaper’s picture

Also, maybe with #2336597: Convert path aliases to full featured entities, this will be solved automatically. Needs to test when path alias are entities if it will be ok.

Grimreaper’s picture

Assigned: Unassigned » Grimreaper
Grimreaper’s picture

Title: Investigate Pathauto » Pathauto support
Assigned: Grimreaper » Unassigned
Status: Active » Needs review
FileSize
13.76 KB

Here is a patch that adds an field enhancer to allow to expose pathauto state.

See automated tests for the behavior.

Also, I won't be able to commit the patch (at least the tests) because of deprecation warnings in Pathauto.

  • Grimreaper authored 9c610f5 on 8.x-2.x
    Issue #3064320 by Grimreaper: Pathauto support
    
Grimreaper’s picture

Status: Needs review » Fixed

Merged.

Tests separated in a dedicated issue: #3089850: Tests: Pathauto support

Status: Fixed » Closed (fixed)

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