You are here

protected function RestfulEntityBase::updateEntity in RESTful 7

Update an entity.

Parameters

$id: The ID to load the entity.

bool $null_missing_fields: Determine if properties that are missing form the request array should be treated as NULL, or should be skipped. Defaults to FALSE, which will skip missing the fields to NULL.

Return value

array Array with the output of the new entity, passed to RestfulEntityInterface::viewEntity().

Overrides RestfulDataProviderEFQ::updateEntity

2 calls to RestfulEntityBase::updateEntity()
RestfulEntityBase::patchEntity in plugins/restful/RestfulEntityBase.php
Update an entity using PATCH.
RestfulEntityBase::putEntity in plugins/restful/RestfulEntityBase.php
Update an entity using PUT.

File

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

Class

RestfulEntityBase
An abstract implementation of RestfulEntityInterface.

Code

protected function updateEntity($id, $null_missing_fields = FALSE) {
  $entity_id = $this
    ->getEntityIdByFieldId($id);
  $this
    ->isValidEntity('update', $entity_id);
  $wrapper = entity_metadata_wrapper($this->entityType, $entity_id);
  $this
    ->setPropertyValues($wrapper, $null_missing_fields);

  // Set the HTTP headers.
  $this
    ->setHttpHeaders('Status', 201);
  if (!empty($wrapper->url) && ($url = $wrapper->url
    ->value())) {
    $this
      ->setHttpHeaders('Location', $url);
  }
  return array(
    $this
      ->viewEntity($wrapper
      ->getIdentifier()),
  );
}