function calendar_systems_entity_type_alter in Calendar Systems 8.3
Implements hook_entity_type_alter().
Parameters
array $entity_types:
File
- ./
calendar_systems.module, line 107
Code
function calendar_systems_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', CalendarSystemsContentTranslationHandler::class);
continue;
}
$handler = $type
->getHandlerClass('translation');
if (!in_array($handler, $supported, TRUE)) {
continue;
}
$handler = explode('\\', $handler);
$handler = array_pop($handler);
$type
->setHandlerClass('translation', '\\Drupal\\calendar_systems\\TranslationHack\\CalendarSystems' . $handler);
}
}