You are here

class EntityShareSerializedDataEnhancer in Entity Share 8.3

Prepare paragraph serialized data value.

Plugin annotation


@ResourceFieldEnhancer(
  id = "entity_share_serialized_data",
  label = @Translation("Serialized Data (Entity Share)"),
  description = @Translation("Prepare serialized data to be shared."),
)

Hierarchy

Expanded class hierarchy of EntityShareSerializedDataEnhancer

File

src/Plugin/jsonapi/FieldEnhancer/EntityShareSerializedDataEnhancer.php, line 19

Namespace

Drupal\entity_share\Plugin\jsonapi\FieldEnhancer
View source
class EntityShareSerializedDataEnhancer extends ResourceFieldEnhancerBase {

  /**
   * {@inheritdoc}
   */
  protected function doTransform($data, Context $context) {
    return is_array($data) ? [
      'value' => $data,
    ] : $data;
  }

  /**
   * {@inheritdoc}
   */
  protected function doUndoTransform($data, Context $context) {
    return !empty($data['value']) ? $data['value'] : $data;
  }

  /**
   * {@inheritdoc}
   */
  public function getOutputJsonSchema() {
    return [
      'type' => 'object',
    ];
  }

}

Members