You are here

public function DataProviderResource::merge in RESTful 7.2

Create or update an item based on the payload.

Parameters

mixed $identifier: The resource item identifier.

mixed $object: The payload.

Return value

mixed The identifier of the created or updated resource item.

Overrides DataProviderResourceInterface::merge

File

src/Plugin/resource/DataProvider/DataProviderResource.php, line 132
Contains \Drupal\restful\Plugin\resource\DataProvider\DataProviderResource.

Class

DataProviderResource
This data provider creates a resource and uses it to access the data.

Namespace

Drupal\restful\Plugin\resource\DataProvider

Code

public function merge($identifier, $object) {
  if (!$identifier) {
    return $this->referencedDataProvider
      ->create($object);
  }
  $replace = ($method = $this
    ->getRequest()
    ->getMethod()) ? $method == RequestInterface::METHOD_PUT : FALSE;
  return $this->referencedDataProvider
    ->update($identifier, $object, $replace);
}