You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure how comprehensive this function is. Access checking seems like a good addition to our API as well, but I don't think we have this integrated in core yet. Another good core candidate though.
The text was updated successfully, but these errors were encountered:
very simple addition which would definitely ease migration since entity is a critical piece of most D7 anythings.
/**
* Determines whether the given user can perform actions on an entity.
*
* For create operations, the pattern is to create an entity and then
* check if the user has create access.
*
* @code
* $node = entity_create('node', array('type' => 'page'));
* $access = entity_access('create', 'node', $node, $account);
* @endcode
*
* @param $op
* The operation being performed. One of 'view', 'update', 'create' or
* 'delete'.
* @param $entity_type
* The entity type of the entity to check for.
* @param $entity
* Optionally an entity to check access for. If no entity is given, it will be
* determined whether access is allowed for all entities of the given type.
* @param $account
* The user to check for. Leave it to NULL to check for the global user.
*
* @return boolean
* Whether access is allowed or not. If the entity type does not specify any
* access information, NULL is returned.
*
* @see entity_type_supports()
*/
function entity_access($op, $entity_type, $entity = NULL, $account = NULL) {
if (($info = entity_get_info()) && isset($info[$entity_type]['access callback'])) {
return $info[$entity_type]['access callback']($op, $entity, $account, $entity_type);
}
}
This was mentioned in backdrop-ops/contrib#71 (comment)
The text was updated successfully, but these errors were encountered: