function datex_entity_type_alter in Datex 8
Implements hook_entity_type_alter().
File
- ./
datex.module, line 97
Code
function datex_entity_type_alter(array &$entity_types) {
$supported = [
BlockContentTranslationHandler::class,
CommentTranslationHandler::class,
ContentTranslationHandler::class,
NodeTranslationHandler::class,
ProfileTranslationHandler::class,
TermTranslationHandler::class,
];
if (!\Drupal::moduleHandler()
->moduleExists('content_translation')) {
return;
}
/** @var \Drupal\Core\Entity\EntityTypeInterface $type */
foreach ($entity_types as $type) {
if (!$type
->isTranslatable()) {
continue;
}
if (!$type
->hasHandlerClass('translation')) {
$type
->setHandlerClass('translation', DatexContentTranslationHandler::class);
continue;
}
$handler = $type
->getHandlerClass('translation');
if (!in_array($handler, $supported, TRUE)) {
continue;
}
$handler = explode('\\', $handler);
$handler = array_pop($handler);
$type
->setHandlerClass('translation', '\\Drupal\\datex\\TranslationHack\\Datex' . $handler);
}
}