function multiversion_entity_base_field_info_alter in Multiversion 8
Same name and namespace in other branches
- 8.2 multiversion.module \multiversion_entity_base_field_info_alter()
Implements hook_entity_base_field_info_alter().
Parameters
array $fields:
\Drupal\Core\Entity\EntityTypeInterface $entity_type:
File
- ./
multiversion.module, line 255
Code
function multiversion_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
/** @var \Drupal\multiversion\MultiversionManagerInterface $manager */
$manager = \Drupal::service('multiversion.manager');
if ($manager
->allowToAlter($entity_type)) {
$exclude_fields = [
$entity_type
->getKey('id'),
$entity_type
->getKey('revision'),
$entity_type
->getKey('uuid'),
$entity_type
->getKey('bundle'),
$entity_type
->getKey('langcode'),
'workspace',
'_deleted',
'_rev',
];
if ($entity_type
->id() == 'comment') {
$exclude_fields[] = 'comment_type';
}
foreach ($fields as $key => $field) {
if (!in_array($key, $exclude_fields)) {
$field
->setRevisionable(TRUE);
}
}
}
}