Problem/Motivation
The hook_entity_create_access() is not useful when the access should be determined for a specific bundle.
Proposed resolution
The #2204363: [sechole] Returning TRUE from hook_entity_access()/hook_ENTITYTYPE_access() must not bypass EntityAccessController::checkAccess() solves this problem partially by providing the entity_create_access alter hook, where also the entity_bundle info is passed in. So the changes for the createAccess() method should fix this issue. However I am not sure what to do with the remaining hooks because I believe the bundle info should be passed in as well.
Remaining tasks
Implement
User interface changes
-
API changes
Introduction of alter hooks for entity/ENTITY_TYPE_create_access().
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2321341-bundle_info_for_entity_access_hooks-6.patch | 4.23 KB | blueminds |
| #5 | 2321341-bundle_info_for_entity_access_hooks-4.patch | 3.79 KB | blueminds |
| #1 | 2321341-bundle_info_for_entity_access_hooks-1.patch | 2.74 KB | blueminds |
Comments
Comment #1
blueminds commentedSo for the moment only the extracted part from the above mentioned issue. Please provide info if it is appropriate to also pass in the bundle info for the access hooks.
Also I think it will need a change record? and definitely documentation update.
Comment #3
berdirThe patch now also includes the default/check access method rename and the alter hook, which currently doesn't exist. Let's limit this to nothing but the hook arguments change, also remember to update the hook documentation.
Comment #5
blueminds commentedUpdating the patch to only add the entity_bundle parameter to the hooks.
Comment #6
blueminds commentedUpdated the hook arguments - passing in the context instead the langcode only.
Comment #8
dawehnerThe createAccess method on the access control handler has the following signature:
public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array()) {I think a little bit more symmetry would be really ncie!Comment #9
berdirYeah, but this is the same as checkCreateAccess() :)
Let's unify all to the same, then.. and probably easier to change the hook + check method than the public API.
Comment #10
dawehnerOH, I haven't realized that.
Comment #11
alexpottNeed to update https://www.drupal.org/node/2095227
Committed bf28ded and pushed to 8.0.x. Thanks!
Comment #13
berdirAdded the new argument to the change record, thanks!