class CoreFieldDiffParser in Entity Share 8.3
Plugin to diff core field types.
Plugin annotation
@DiffGenerator(
  id = "core_field_diff_parser",
  label = @Translation("Core Field Parser"),
  field_types = {
    "decimal",
    "integer",
    "float",
    "email",
    "telephone",
    "date",
    "uri",
    "string",
    "timestamp",
    "created",
    "string_long",
    "language",
    "uuid",
    "map",
    "datetime",
    "boolean"
  },
)
  Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\entity_share_diff\DiffGenerator\DiffGeneratorPluginBase implements ContainerFactoryPluginInterface, DiffGeneratorInterface uses StringTranslationTrait
- class \Drupal\entity_share_diff\Plugin\DiffGenerator\CoreFieldDiffParser
 
 
 - class \Drupal\entity_share_diff\DiffGenerator\DiffGeneratorPluginBase implements ContainerFactoryPluginInterface, DiffGeneratorInterface uses StringTranslationTrait
 
Expanded class hierarchy of CoreFieldDiffParser
File
- modules/
entity_share_diff/ src/ Plugin/ DiffGenerator/ CoreFieldDiffParser.php, line 36  
Namespace
Drupal\entity_share_diff\Plugin\DiffGeneratorView source
class CoreFieldDiffParser extends DiffGeneratorPluginBase {
  /**
   * {@inheritdoc}
   */
  public function build(FieldItemListInterface $field_items, array $remote_field_data = []) {
    $result = [];
    $definition = $field_items
      ->getFieldDefinition();
    $type = $definition
      ->getType();
    // Every item from $field_items is of type FieldItemInterface.
    foreach ($field_items as $field_key => $field_item) {
      if (!$field_item
        ->isEmpty()) {
        $values = $field_item
          ->getValue();
        if (isset($values['value'])) {
          $result[$field_key] = $values['value'];
          if ($type == 'boolean') {
            $result[$field_key] = $result[$field_key] == 1;
          }
          elseif (in_array($type, [
            'float',
            'integer',
            'decimal',
            'timestamp',
          ])) {
            $result[$field_key] = (string) $result[$field_key];
          }
        }
      }
    }
    return $result;
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            CoreFieldDiffParser:: | 
                  public | function | 
            Builds an array of strings. Overrides DiffGeneratorInterface:: | 
                  |
| 
            DiffGeneratorPluginBase:: | 
                  protected | property | The entity parser service. | |
| 
            DiffGeneratorPluginBase:: | 
                  protected | property | The entity type manager. | |
| 
            DiffGeneratorPluginBase:: | 
                  protected | property | The 'Remote' entity. | |
| 
            DiffGeneratorPluginBase:: | 
                  protected | property | The remote manager service. | |
| 
            DiffGeneratorPluginBase:: | 
                  public static | function | 
            Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: | 
                  |
| 
            DiffGeneratorPluginBase:: | 
                  public | function | Returns Remote entity. | |
| 
            DiffGeneratorPluginBase:: | 
                  public static | function | 
            Returns if the plugin can be used for the provided field. Overrides DiffGeneratorInterface:: | 
                  |
| 
            DiffGeneratorPluginBase:: | 
                  public | function | Sets Remote entity. | |
| 
            DiffGeneratorPluginBase:: | 
                  public | function | 
            Constructs a DiffManagerBase object. Overrides PluginBase:: | 
                  |
| 
            PluginBase:: | 
                  protected | property | Configuration information passed into the plugin. | 1 | 
| 
            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. | |
| 
            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. |