You are here

public function ServicesEntityResourceController::create in Services Entity API 7.2

Implements ServicesResourceControllerInterface::create().

Overrides ServicesResourceControllerInterface::create

1 method overrides ServicesEntityResourceController::create()
ServicesEntityResourceControllerClean::create in plugins/services_entity_resource_clean.inc
Implements ServicesResourceControllerInterface::create().

File

plugins/services_entity_resource.inc, line 45

Class

ServicesEntityResourceController
Generic controller for entity-bases resources.

Code

public function create($entity_type, array $values) {
  $this
    ->checkTextFormatAccess($values);
  $entity = entity_create($entity_type, $values);
  entity_save($entity_type, $entity);
  list($id, ) = entity_extract_ids($entity_type, $entity);

  // Check we got an ID back for the new entity.
  if (!isset($id)) {
    services_error('Error saving entity.', 406);
  }
  return $entity;
}