Remove taxonomy_machine_name dependency

Created on 26 January 2023, almost 2 years ago
Updated 1 February 2023, almost 2 years ago

Problem/Motivation

It would be nice to remove the taxonomy_machine_name dependency and allow the machine name to be configurable.

This can be done by making the machine name field configurable. In the patch below, I do this by setting 'machine_name' as the default, but letting devs override this via $settings. If the machine name field is not available on the taxonomy term, this simply falls back to the term ID.

Steps to reproduce

n/a

Proposed resolution

n/a

Remaining tasks

Check the patch.

User interface changes

n/a

API changes

n/a

Data model changes

n/a

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇸🇮Slovenia alecsmrekar

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

Comments & Activities

  • Issue created by @alecsmrekar
  • Status changed to Needs work almost 2 years ago
  • 🇮🇹Italy plach Venezia
    +++ b/src/Plugin/facets_pretty_paths/coder/TaxonomyTermCoder.php
    @@ -71,4 +73,14 @@ class TaxonomyTermCoder extends CoderPluginBase {
    +    return Settings::get('facets_short_pretty_paths_field_name','machine_name');
    

    Nit: missing space after comma, looks good to me otherwise.

    We'd also need some README update to mention how this can be leveraged.

  • Status changed to Needs review almost 2 years ago
  • 🇨🇭Switzerland colorfield Lausanne

    Thanks! This is brilliant / a lightweight way to have soft dependency with BC.
    Adjusted the readme + space, added accessCheck on entityQuery with re-roll for 📌 Automated Drupal 10 compatibility fixes Fixed .
    For some reason interdiff is not playing well here, so not posting it.

    If the UI is wanted at some point, we could still provide it in a follow up. Just wondering if this should be in the facet source config form, in this case that could potentially open to different field configurations (even though, i don't see the use case for that). Probably better to keep it simple as it is for now.

  • Status changed to RTBC almost 2 years ago
  • 🇮🇹Italy plach Venezia

    Looks good to me, thanks!

    If the UI is wanted at some point, we could still provide it in a follow up. Just wondering if this should be in the facet source config form, in this case that could potentially open to different field configurations (even though, i don't see the use case for that). Probably better to keep it simple as it is for now.

    Agreed, if it turns out we need to make this configurable, it's easy enough to add it to the configuration form. The main reason we need this, is that a new requirement came up and we now need pretty facets, but we already have a "legacy machine name" field in place, so I'd expect most people will just use the module as before.

    If we want to make things even smoother, we could add an installation requirement checking that a field storage definition matching the configured field name exists, or at least that Taxonomy Machine Name is enabled if the field name is machine_name.

  • Status changed to Fixed almost 2 years ago
  • 🇨🇭Switzerland colorfield Lausanne

    Pushed.
    Thanks for the input :) Created 📌 Check if the field used by the taxonomy coder exists Fixed follow up, when this one is done i will create a new release.
    Perhaps we could also have a default computed field.

    The hard dependency was not so nice, that's also discussed here https://www.drupal.org/project/facets_pretty_paths/issues/2878617#commen... so we have a good first step to solve this.

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

Production build 0.71.5 2024