Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Spin-off from #1696660: Add an entity access API for single entity access (see comment #89 / #90 / #91).
Currently (once the patch in that issue is committed) we do support custom $operations for custom entity types. However, it is not possible to add support for custom $operations on already existing entity types. Let's discuss if we actually need that feature and, if we do, how we would implement that.
Currently, form controllers have something similiar: You can easily add custom form controllers to an existing entity type. Do we want to add something similiar for single entity access?
Comments
Comment #1
hefox CreditAttribution: hefox commentedI think if there's a clean way to do it, it'd be quite useful for things like premium access/etc.
Take the node entity as example. A "featured content" type module could add an op "feature" and then people could customize how access to feature a node is done, instead of having to have a separate access system for featuring. (e.g. instead of flag having flag access, it could use entity access with ops for flags -- for example). Not sure if that's the best example.
Premium content is one used in those comments -- it wants a different access to "full" content vs "teaser content" (as people pay to view the premium content). In d6 it had to do it a hacky (alter node via node_view, but course views/etc. doesn't always go through node_view). way that could lead to contrib modules exposing data that they wanted to keep hidden.
Comment #2
sunI think this duplicates #1839516: Introduce entity operation providers