class JSONFieldEnhancer in JSON:API Extras 8.3
Same name and namespace in other branches
- 8.2 src/Plugin/jsonapi/FieldEnhancer/JSONFieldEnhancer.php \Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\JSONFieldEnhancer
Perform additional manipulations to JSON fields.
Plugin annotation
@ResourceFieldEnhancer(
id = "json",
label = @Translation("JSON Field"),
description = @Translation("Render JSON Field has real json")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase implements ResourceFieldEnhancerInterface uses \Shaper\DataAdaptor\DataAdaptorValidatorTrait, \Shaper\DataAdaptor\DataAdaptorTransformerTrait
- class \Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\JSONFieldEnhancer implements ContainerFactoryPluginInterface
- class \Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase implements ResourceFieldEnhancerInterface uses \Shaper\DataAdaptor\DataAdaptorValidatorTrait, \Shaper\DataAdaptor\DataAdaptorTransformerTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of JSONFieldEnhancer
File
- src/
Plugin/ jsonapi/ FieldEnhancer/ JSONFieldEnhancer.php, line 20
Namespace
Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancerView source
class JSONFieldEnhancer extends ResourceFieldEnhancerBase implements ContainerFactoryPluginInterface {
/**
* The serialization json.
*
* @var Drupal\Component\serialization\Json
*/
protected $encoder;
/**
* Constructs a new JSONFieldEnhancer.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Component\Serialization\Json $encoder
* The serialization json.
*/
public function __construct(array $configuration, string $plugin_id, $plugin_definition, Json $encoder) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->encoder = $encoder;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('serialization.json'));
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function doUndoTransform($data, Context $context) {
return $this->encoder
->decode($data);
}
/**
* {@inheritdoc}
*/
protected function doTransform($data, Context $context) {
return $this->encoder
->encode($data);
}
/**
* {@inheritdoc}
*/
public function getOutputJsonSchema() {
return [
'oneOf' => [
[
'type' => 'object',
],
[
'type' => 'array',
],
[
'type' => 'null',
],
],
];
}
/**
* {@inheritdoc}
*/
public function getSettingsForm(array $resource_field_info) {
return [];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
JSONFieldEnhancer:: |
protected | property | The serialization json. | |
JSONFieldEnhancer:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
JSONFieldEnhancer:: |
public | function |
Overrides ResourceFieldEnhancerBase:: |
|
JSONFieldEnhancer:: |
protected | function | ||
JSONFieldEnhancer:: |
public | function | ||
JSONFieldEnhancer:: |
public | function |
Get the JSON Schema for the new output. Overrides ResourceFieldEnhancerInterface:: |
|
JSONFieldEnhancer:: |
public | function |
Get a form element to render the settings. Overrides ResourceFieldEnhancerBase:: |
|
JSONFieldEnhancer:: |
public | function |
Constructs a new JSONFieldEnhancer. Overrides PluginBase:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
ResourceFieldEnhancerBase:: |
protected | property |
Holds the plugin configuration. Overrides PluginBase:: |
|
ResourceFieldEnhancerBase:: |
public | function | ||
ResourceFieldEnhancerBase:: |
public | function | ||
ResourceFieldEnhancerBase:: |
public | function | ||
ResourceFieldEnhancerBase:: |
public | function | ||
ResourceFieldEnhancerBase:: |
public | function | ||
ResourceFieldEnhancerBase:: |
public | function | ||
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |