Define xb_path entity key for identifying entity path field

Created on 30 January 2025, 2 months ago

Overview

#3500052-27: Provide HTTP API for listing Page content entities that can be updated by the current user β†’ identified a follow up where the content listing API returns paths that include the site's subdirectory (if in one.) We do not want to show the generated path in is entirety, we want to show the path it has.

Proposed resolution

Implement our own xb_path entity key, which is used to specify the path field used by an entity. We will update the Page entity type to have this and can use hook_entity_type_build to provide it for Nodes.

Path fields are a computed field:

    // @see path_entity_base_field_info().
    $fields['path'] = BaseFieldDefinition::create('path')
      ->setLabel(t('URL alias'))
      ->setTranslatable(TRUE)
      ->setDisplayOptions('form', [
        'type' => 'path',
      ])
      ->setDisplayConfigurable('form', TRUE)
      ->setComputed(TRUE);

The value is computed in \Drupal\path\Plugin\Field\FieldType\PathFieldItemList::computeValue.

Problem: if the entity does not have an alias, then the value will be blank and not display the normal /{entity_type}/{entity_id} path from its canonical template

User interface changes

πŸ“Œ Task
Status

Active

Version

0.0

Component

Page

Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024