Skip to content
Snippets Groups Projects
Commit b365a150 authored by Josh Stevenson-Woods's avatar Josh Stevenson-Woods
Browse files

Merge branch '3036499-content-moderation-state-group' into '8.x-1.x'

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

See merge request !4
parents cfe1d249 50740d10
No related branches found
No related tags found
No related merge requests found
Pipeline #82001 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