I’m trying to restrict the access to my custom entity. To do so, I create my class
EntityTestAccessControlHandler (let’s say that my entity is named EntityTest), I extend it with
EntityAccessControlHandler and I override the function
checkAccess(). Easy for now and it works well.
Thing is, when I create a view to list all my EntityTests, they will show up, even if I restricted the access with
checkAccess(). I found a workaround to this ! I override the function
checkFieldAccess() instead and it works.
But now, I have another problem ! My entities appears as well when I use an entity reference field and I cannot find a solution to this for now.
So I would like to be able to control whenever I want that my entities appears or not in the list of an entity reference field.
You can imagine, I’m trying to find an alternative to the
hook_node_access_records() functions because they are specific to nodes, and I’m using a custom entity here.
Do you have any idea how to deal with entity access in a more deep level ?
Thank you very much.
Have a nice day.