TestLighterTextPlugin.php in Diff 8
File
tests/modules/diff_test/src/Plugin/diff/Field/TestLighterTextPlugin.php
View source
<?php
namespace Drupal\diff_test\Plugin\diff\Field;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\diff\FieldDiffBuilderBase;
use Drupal\Core\Field\FieldItemListInterface;
class TestLighterTextPlugin extends FieldDiffBuilderBase {
public function build(FieldItemListInterface $field_items) {
$result = [];
foreach ($field_items as $field_key => $field_item) {
if (!$field_item
->isEmpty()) {
$values = $field_item
->getValue();
if (isset($values['value'])) {
$result[$field_key][] = str_replace('applicable', 'lighter_test_plugin', $values['value']);
}
}
}
return $result;
}
public static function isApplicable(FieldStorageDefinitionInterface $field_definition) {
return $field_definition
->getName() == 'test_field_lighter';
}
}