You are here

public function EntityMetadataWrapper::access in Entity API 7

Determines whether the given user has access to view or edit this property. Apart from relying on access metadata of properties, this takes into account information about entity level access, if available:

  • Referenced entities can only be viewed, when the user also has permission to view the entity.
  • A property may be only edited, if the user has permission to update the entity containing the property.

Parameters

$op: The operation being performed. One of 'view' or 'edit.

$account: The user to check for. Leave it to NULL to check for the global user.

Return value

bool Whether access to entity property is allowed for the given operation. However if we wrap no data, it returns whether access is allowed to the property of all entities of this type. If there is no access information for this property, TRUE is returned.

2 calls to EntityMetadataWrapper::access()
EntityDrupalWrapper::access in includes/entity.wrapper.inc
Note that this method checks property access, but can be used for checking entity access *only* if the wrapper is not a property (i.e. has no parent wrapper). To be safe, better use EntityDrupalWrapper::entityAccess() for checking entity access.
EntityListWrapper::propertyAccess in includes/entity.wrapper.inc
1 method overrides EntityMetadataWrapper::access()
EntityDrupalWrapper::access in includes/entity.wrapper.inc
Note that this method checks property access, but can be used for checking entity access *only* if the wrapper is not a property (i.e. has no parent wrapper). To be safe, better use EntityDrupalWrapper::entityAccess() for checking entity access.

File

includes/entity.wrapper.inc, line 235
Provides wrappers allowing easy usage of the entity metadata.

Class

EntityMetadataWrapper
A common base class for all wrappers.

Code

public function access($op, $account = NULL) {
  return !empty($this->info['parent']) ? $this->info['parent']
    ->propertyAccess($this->info['name'], $op, $account) : TRUE;
}