If you specify an entity clone handler for an entity type, you must also specify an entity clone form handler, because the mechanism for setting a default entity clone form fails when an entity clone handler is set.
Doing this doesn't work properly:
function my_module_entity_type_build(array &$entity_types) {
$entity_types['my_entity']->setHandlerClass('entity_clone', \Drupal\my_module\EntityClone\MyEntityEntityClone::class);
}
instead you have to do this, which is silly:
function my_module_entity_type_build(array &$entity_types) {
$entity_types['my_entity']->setHandlerClass('entity_clone', \Drupal\my_module\EntityClone\MyEntityEntityClone::class);
$entity_types['my_entity']->setHandlerClass('entity_clone_form', \Drupal\entity_clone\EntityClone\Content\ContentEntityCloneFormBase::class);
}
Fix the current code:
function entity_clone_entity_type_build(array &$entity_types) {
...
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
foreach ($entity_types as $entity_type_id => $entity_type) {
$has_entity_clone_handler = $entity_type->getHandlerClass('entity_clone');
if (!$has_entity_clone_handler) {
if ($entity_type instanceof ContentEntityTypeInterface) {
$entity_type->setHandlerClass('entity_clone', ContentEntityCloneBase::class);
$entity_type->setHandlerClass('entity_clone_form', ContentEntityCloneFormBase::class);
}
elseif ($entity_type instanceof ConfigEntityTypeInterface) {
$entity_type->setHandlerClass('entity_clone', ConfigEntityCloneBase::class);
$entity_type->setHandlerClass('entity_clone_form', ConfigEntityCloneFormBase::class);
}
}
to something like this:
function entity_clone_entity_type_build(array &$entity_types) {
...
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
foreach ($entity_types as $entity_type_id => $entity_type) {
$has_entity_clone_handler = $entity_type->getHandlerClass('entity_clone');
$has_entity_clone_form_handler = $entity_type->getHandlerClass('entity_clone_form');
$isContent = $entity_type instanceof ContentEntityTypeInterface;
$isConfig = $entity_type instanceof ConfigEntityTypeInterface;
if (!$has_entity_clone_handler && $isContent) {
$entity_type->setHandlerClass('entity_clone', ContentEntityCloneBase::class);
}
elseif (!$has_entity_clone_handler && $isConfig) {
$entity_type->setHandlerClass('entity_clone', ConfigEntityCloneBase::class);
}
if (!$has_entity_clone_form_handler && $isContent) {
$entity_type->setHandlerClass('entity_clone_form', ContentEntityCloneBase::class);
}
elseif (!$has_entity_clone_form_handler && $isConfig) {
$entity_type->setHandlerClass('entity_clone_form', ConfigEntityCloneBase::class);
}
None.
None.
None.
Active
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.