You are here

public function ServicesEntityResourceControllerClean::access in Services Entity API 7.2

Overrides ServicesEntityResourceController::access

See also

ServicesEntityResourceController::access()

File

plugins/services_entity_resource_clean.inc, line 17

Class

ServicesEntityResourceControllerClean
This class is designed to create a very clean API that integrates with the services and entity modules. We want to strip all "drupalisms" out of the API. For example, there should be no [LANGUAGE_NONE][0][value] or field_ in the API.

Code

public function access($op, $args) {
  if ($op == 'create') {
    list($entity_type, $data) = $args;

    // Workaround for bug in Entity API node access.
    // @todo remove once https://drupal.org/node/1780646 lands.
    if ($entity_type == 'node') {
      return isset($data['type']) ? node_access('create', $data['type']) : FALSE;
    }

    // Create a wrapper from the entity so we can call its access() method.
    $wrapper = $this
      ->createWrapperFromValues($entity_type, $data);
    return $wrapper
      ->entityAccess('create');
  }
  else {
    return parent::access($op, $args);
  }
}