/**
  * Modifies an entity definition to include moderation support.
  *
  * This primarily just means an extra handler. A Generic one is provided,
  * but individual entity types can provide their own as appropriate.
  *
  * @param \Drupal\Core\Entity\ContentEntityTypeInterface $type
  *   The content entity definition to modify.
  *
  * @return \Drupal\Core\Entity\ContentEntityTypeInterface
  *   The modified content entity definition.
  */
 protected function addModerationToEntity(ContentEntityTypeInterface $type)
 {
     if (!$type->hasHandlerClass('moderation')) {
         $handler_class = !empty($this->moderationHandlers[$type->id()]) ? $this->moderationHandlers[$type->id()] : ModerationHandler::class;
         $type->setHandlerClass('moderation', $handler_class);
     }
     if (!$type->hasLinkTemplate('latest-version')) {
         $type->setLinkTemplate('latest-version', $type->getLinkTemplate('canonical') . '/latest');
     }
     // @todo Core forgot to add a direct way to manipulate route_provider, so
     // we have to do it the sloppy way for now.
     $providers = $type->getRouteProviderClasses() ?: [];
     if (empty($providers['moderation'])) {
         $providers['moderation'] = EntityModerationRouteProvider::class;
         $type->setHandlerClass('route_provider', $providers);
     }
     return $type;
 }