hook_entity_type_alter: Ability to remove a link template

Created on 1 April 2020, over 4 years ago
Updated 29 July 2024, 5 months ago

Problem

I want to remove a link template added by another module (handled by the EntityType subsystem/class) or override it with a custom uri_callback function. The natural place to do this would be in a hook_entity_type_alter. However, there is no way to remove a link template once it has been defined.

Suggestion

Provide a new method ::removeLinkTemplate($key) which will allow developers to easily remove a link template.

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
EntityΒ  β†’

Last updated about 16 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States AndyThornton

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue under control, following Review a patch or merge request β†’ as a guide.

    New function should be typehinted.
    Will need test coverage
    When solution is agreed upon it should be added to the issue summary.
    Change record will be needed as well.

  • First commit to issue fork.
  • Merge request !8967Add ::removeLinkTemplate() method. β†’ (Open) created by vensires
  • Pipeline finished with Success
    5 months ago
    Total: 399s
    #237311
  • πŸ‡¬πŸ‡·Greece vensires

    I fell into this issue when trying to override another entity type's links definition due to the fact that without it I couldn't use the "uri_callback" property.

    I have created a MR with the changes mortim07 added. I also checked Drupal core code and it seems that "remove" is more commonly used than "unset" (like Niklan proposed) or even "delete". For example, we have "removeDefinition", "removeListener", "removeSubscriber" etc. So "removeLinkTemplate" is the way to go.

    I have also updated the issue summary. So, if there are no objections, the only thing missing is the writing of the tests.

  • πŸ‡¬πŸ‡·Greece vensires

    Adding some related issues I found which may guide us on whether we really do want this functionality or another workaround should be found to achieve what we want in general.

Production build 0.71.5 2024