You are here

protected function RestfulEntityBase::checkPropertyAccessByAccessCallbacks in RESTful 7

Check access on property by the defined access callbacks.

Parameters

string $op: The operation that access should be checked for. Can be "view" or "edit". Defaults to "edit".

string $public_field_name: The name of the public field.

EntityMetadataWrapper $property_wrapper: The wrapped property.

EntityMetadataWrapper $wrapper: The wrapped entity.

Return value

bool TRUE if the current user has access to set the property, FALSE otherwise. The default implementation assumes that if no callback has explicitly denied access, we grant the user permission.

1 call to RestfulEntityBase::checkPropertyAccessByAccessCallbacks()
RestfulEntityBase::checkPropertyAccess in plugins/restful/RestfulEntityBase.php
Check access on a property.

File

plugins/restful/RestfulEntityBase.php, line 1129
Contains RestfulEntityBase.

Class

RestfulEntityBase
An abstract implementation of RestfulEntityInterface.

Code

protected function checkPropertyAccessByAccessCallbacks($op, $public_field_name, EntityMetadataWrapper $property_wrapper, EntityMetadataWrapper $wrapper) {
  $public_fields = $this
    ->getPublicFields();
  foreach ($public_fields[$public_field_name]['access_callbacks'] as $callback) {
    $result = static::executeCallback($callback, array(
      $op,
      $public_field_name,
      $property_wrapper,
      $wrapper,
    ));
    if ($result == \RestfulInterface::ACCESS_DENY) {
      return FALSE;
    }
  }
  return TRUE;
}