class FieldComparatorDefault in Conflict 8.2
Default field comparator plugin implementation covering all fields.
Plugin annotation
@FieldComparator(
id = "conflict_field_comparator_default",
entity_type_id = "*",
bundle = "*",
field_type = "*",
field_name = "*",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\conflict\Plugin\Conflict\FieldComparator\FieldComparatorDefault implements FieldComparatorInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of FieldComparatorDefault
1 file declares its use of FieldComparatorDefault
- FieldComparatorParagraphReference.php in modules/
conflict_paragraphs/ src/ Plugin/ Conflict/ FieldComparator/ FieldComparatorParagraphReference.php
File
- src/
Plugin/ Conflict/ FieldComparator/ FieldComparatorDefault.php, line 22
Namespace
Drupal\conflict\Plugin\Conflict\FieldComparatorView source
class FieldComparatorDefault extends PluginBase implements FieldComparatorInterface {
/**
* {@inheritdoc}
*/
public function hasChanged(FieldItemListInterface $field_item_list_a, FieldItemListInterface $field_item_list_b, $langcode = NULL, $entity_type_id = NULL, $bundle = NULL, $field_type = NULL, $field_name = NULL) {
$equals = $field_item_list_a
->equals($field_item_list_b);
return !$equals;
}
/**
* {@inheritdoc}
*/
public function getConflictType(FieldItemListInterface $local, FieldItemListInterface $server, FieldItemListInterface $original, $langcode, $entity_type_id, $bundle, $field_type, $field_name) {
// Check for changes between the server and the locally edited version.
if ($this
->hasChanged($server, $local, $langcode, $entity_type_id, $bundle, $field_type, $field_name)) {
// Check for changes between the server and the locally used original
// version.
if ($this
->hasChanged($server, $original, $langcode, $entity_type_id, $bundle, $field_type, $field_name)) {
// Check for changes between the locally edited and locally used
// original version.
$conflict_type = $this
->hasChanged($local, $original, $langcode, $entity_type_id, $bundle, $field_type, $field_name) ? ConflictTypes::CONFLICT_TYPE_LOCAL_REMOTE : ConflictTypes::CONFLICT_TYPE_REMOTE;
return $conflict_type;
}
}
return NULL;
}
/**
* {@inheritdoc}
*/
public static function isApplicable(FieldDefinitionInterface $field_definition) {
// By default, field comparators are available for all fields.
return TRUE;
}
}
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 | |
FieldComparatorDefault:: |
public | function |
Returns the conflict type for a field. Overrides FieldComparatorInterface:: |
1 |
FieldComparatorDefault:: |
public | function |
Checks whether the field items have changed. Overrides FieldComparatorInterface:: |
|
FieldComparatorDefault:: |
public static | function |
Returns if the field comparator can be used for the provided field. Overrides FieldComparatorInterface:: |
1 |
FieldComparatorInterface:: |
constant | The identifier to be used by the plugin annotation and hasChanged(). | ||
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
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. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
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. |