protected EntityTypeInfo::addModerationToEntity(ContentEntityTypeInterface $type)
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.
Parameters
\Drupal\Core\Entity\ContentEntityTypeInterface $type: The content entity definition to modify.
Return value
\Drupal\Core\Entity\ContentEntityTypeInterface The modified content entity definition.
File
- core/modules/content_moderation/src/EntityTypeInfo.php, line 130
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\content_moderation
Code
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->hasLinkTemplate('canonical')) { $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; }
Please login to continue.