ListFieldDiffParser.php in Entity Share 8.3
File
modules/entity_share_diff/src/Plugin/DiffGenerator/ListFieldDiffParser.php
View source
<?php
declare (strict_types=1);
namespace Drupal\entity_share_diff\Plugin\DiffGenerator;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\entity_share_diff\DiffGenerator\DiffGeneratorPluginBase;
class ListFieldDiffParser extends DiffGeneratorPluginBase {
public function build(FieldItemListInterface $field_items, array $remote_field_data = []) {
$result = [];
foreach ($field_items as $field_key => $field_item) {
if (!$field_item
->isEmpty()) {
$possible_options = $field_item
->getPossibleOptions();
$values = $field_item
->getValue();
if ($possible_options) {
$result[$field_key] = $possible_options[$values['value']] . ' (' . $values['value'] . ')';
}
else {
$result[$field_key] = $possible_options[$values['value']];
}
}
}
return $result;
}
}