Skip to content
Snippets Groups Projects

Issue #3036499: Content moderation's moderation state control isn't displayed in the right place when cloning

Merged Issue #3036499: Content moderation's moderation state control isn't displayed in the right place when cloning
+ 31
1
@@ -6,8 +6,10 @@
*/
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\ContentEntityFormInterface;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\group\Entity\GroupContent;
@@ -19,7 +21,6 @@ function quick_node_clone_entity_type_build(array &$entity_types) {
if (isset($entity_types['node'])) {
$entity_types['node']->setFormClass('quick_node_clone', 'Drupal\quick_node_clone\Form\QuickNodeCloneNodeForm');
}
}
/**
@@ -70,6 +71,35 @@ function quick_node_clone_help($route_name, RouteMatchInterface $route_match) {
return NULL;
}
/**
* Implements hook_form_alter().
*/
function quick_node_clone_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (!array_key_exists('footer', $form)) {
return;
}
// Check the operation set on the form is 'quick_node_clone'.
$form_object = $form_state->getFormObject();
if (!$form_object instanceof ContentEntityFormInterface) {
return;
}
if ($form_object->getOperation() !== 'quick_node_clone') {
return;
}
// Check that the content entity being cloned is moderated.
if (!\Drupal::moduleHandler()->moduleExists('content_moderation')) {
return;
}
$moderation_info = \Drupal::service('content_moderation.moderation_information');
if (!$moderation_info->isModeratedEntity($form_object->getEntity())) {
return;
}
$form['moderation_state']['#group'] = 'footer';
}
/**
* Determine if the current user has permission to clone a specified node.
*
Loading