3 namespace Drupal\content_moderation\Form;
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\workflows\Plugin\WorkflowTypeStateFormBase;
7 use Drupal\workflows\StateInterface;
10 * The content moderation state form.
12 * @see \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration
14 class ContentModerationStateForm extends WorkflowTypeStateFormBase {
19 public function buildConfigurationForm(array $form, FormStateInterface $form_state, StateInterface $state = NULL) {
20 /** @var \Drupal\content_moderation\ContentModerationState $state */
21 $state = $form_state->get('state');
22 $is_required_state = isset($state) ? in_array($state->id(), $this->workflowType->getRequiredStates(), TRUE) : FALSE;
25 $form['published'] = [
26 '#type' => 'checkbox',
27 '#title' => $this->t('Published'),
28 '#description' => $this->t('When content reaches this state it should be published.'),
29 '#default_value' => isset($state) ? $state->isPublishedState() : FALSE,
30 '#disabled' => $is_required_state,
33 $form['default_revision'] = [
34 '#type' => 'checkbox',
35 '#title' => $this->t('Default revision'),
36 '#description' => $this->t('When content reaches this state it should be made the default revision; this is implied for published states.'),
37 '#default_value' => isset($state) ? $state->isDefaultRevisionState() : FALSE,
38 '#disabled' => $is_required_state,
39 // @todo Add form #state to force "make default" on when "published" is
41 // @see https://www.drupal.org/node/2645614