Skip to content
Snippets Groups Projects
Commit 8ba9b106 authored by Lawxen Liu's avatar Lawxen Liu
Browse files

Issue #3486672 by lawxen: Create field enhancer text_processed

parent 74541eeb
Branches 1.0.x
Tags 1.0.1
No related merge requests found
{
"name": "drupal/jsonapi_text_enhancer",
"description": "JSON:API Extras - Text Field Enhancer",
"type": "drupal-module",
"license": "GPL-2.0-or-later",
"require": {
"drupal/core": "^10.3 || ^11",
"drupal/jsonapi_extras": "*"
}
}
<?php
namespace Drupal\Jsonapi_text_enhancer\Plugin\jsonapi\FieldEnhancer;
use Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase;
use Shaper\Util\Context;
/**
* Perform additional manipulations to timestamp fields.
*
* @ResourceFieldEnhancer(
* id = "text_processed",
* label = @Translation("Text: Just output processed"),
* description = @Translation("Text: Just output processed."),
* )
*/
class TextEnhancer extends ResourceFieldEnhancerBase
{
/**
* {@inheritdoc}
*/
protected function doUndoTransform($data, Context $context)
{
if (is_array($data)) {
if (isset($data['value'])) {
unset($data['value']);
}
if (isset($data['format'])) {
unset($data['format']);
}
}
return $data;
}
public function getOutputJsonSchema()
{
return [
'type' => 'object',
];
}
protected function doTransform($data, Context $context)
{
return $data;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment