You are here

protected function RestfulEntityBase::createOrUpdateSubResourceItems in RESTful 7

Create, update or return a set of already saved entities.

Parameters

\RestfulInterface $handler: The sub resource handler.

mixed $value: The value passed in the request.

array $field_info: The field info array.

Return value

mixed The value to set using the wrapped property.

1 call to RestfulEntityBase::createOrUpdateSubResourceItems()
RestfulEntityBase::createEntityFromReference in plugins/restful/RestfulEntityBase.php
Helper function; Create an entity from a a sub-resource.

File

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

Class

RestfulEntityBase
An abstract implementation of RestfulEntityInterface.

Code

protected function createOrUpdateSubResourceItems(\RestfulInterface $handler, $value, $field_info) {

  // Return the entity ID that was created.
  if ($field_info['cardinality'] == 1) {

    // Single value.
    return $this
      ->createOrUpdateSubResourceItem($value, $handler);
  }

  // Multiple values.
  $return = array();
  foreach ($value as $value_item) {
    $return[] = $this
      ->createOrUpdateSubResourceItem($value_item, $handler);
  }
  return $return;
}