EntityShareSerializedDataEnhancer.php in Entity Share 8.3
File
src/Plugin/jsonapi/FieldEnhancer/EntityShareSerializedDataEnhancer.php
View source
<?php
declare (strict_types=1);
namespace Drupal\entity_share\Plugin\jsonapi\FieldEnhancer;
use Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase;
use Shaper\Util\Context;
class EntityShareSerializedDataEnhancer extends ResourceFieldEnhancerBase {
protected function doTransform($data, Context $context) {
return is_array($data) ? [
'value' => $data,
] : $data;
}
protected function doUndoTransform($data, Context $context) {
return !empty($data['value']) ? $data['value'] : $data;
}
public function getOutputJsonSchema() {
return [
'type' => 'object',
];
}
}