Skip to content
Snippets Groups Projects
Commit 794ff08c authored by Josh Stevenson-Woods's avatar Josh Stevenson-Woods Committed by Mark Dorison
Browse files

Issue #3036499 by jkswoods, dgsiegel, markdorison, kala4ek, Eli-T: Content...

Issue #3036499 by jkswoods, dgsiegel, markdorison, kala4ek, Eli-T: Content moderation's moderation state control isn't displayed in the right place when cloning 
parent cfe1d249
Branches
Tags 2.0.13
1 merge request!4Issue #3036499: Content moderation's moderation state control isn't displayed in the right place when cloning
Pipeline #82013 passed
......@@ -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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment