/** * Returns an array of transition permissions. * * @return array * The transition permissions. */ public function transitionPermissions() { // @todo write a test for this. $perms = []; /* @var \Drupal\workbench_moderation\ModerationStateInterface[] $states */ $states = ModerationState::loadMultiple(); /* @var \Drupal\workbench_moderation\ModerationStateTransitionInterface $transition */ foreach (ModerationStateTransition::loadMultiple() as $id => $transition) { $perms['use ' . $id . ' transition'] = ['title' => $this->t('Use the %transition_name transition', ['%transition_name' => $transition->label()]), 'description' => $this->t('Move content from %from state to %to state.', ['%from' => $states[$transition->getFromState()]->label(), '%to' => $states[$transition->getToState()]->label()])]; } return $perms; }
/** * Tests workbench moderation third party schema for block content types. */ public function testWorkbenchModerationBlockContentTypeConfig() { $this->installEntitySchema('block_content'); $this->installEntitySchema('user'); $this->installConfig(['workbench_moderation']); $typed_config = \Drupal::service('config.typed'); $moderation_states = ModerationState::loadMultiple(); $block_content_type = BlockContentType::create(['id' => 'basic', 'label' => 'basic', 'revision' => TRUE]); $block_content_type->setThirdPartySetting('workbench_moderation', 'enabled', TRUE); $block_content_type->setThirdPartySetting('workbench_moderation', 'allowed_moderation_states', array_keys($moderation_states)); $block_content_type->setThirdPartySetting('workbench_moderation', 'default_moderation_state', ''); $block_content_type->save(); $this->assertConfigSchema($typed_config, $block_content_type->getEntityType()->getConfigPrefix() . '.' . $block_content_type->id(), $block_content_type->toArray()); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); /* @var \Drupal\workbench_moderation\ModerationStateTransitionInterface $moderation_state_transition */ $moderation_state_transition = $this->entity; $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $moderation_state_transition->label(), '#description' => $this->t("Label for the Moderation state transition."), '#required' => TRUE]; $form['id'] = ['#type' => 'machine_name', '#default_value' => $moderation_state_transition->id(), '#machine_name' => ['exists' => '\\Drupal\\workbench_moderation\\Entity\\ModerationStateTransition::load'], '#disabled' => !$moderation_state_transition->isNew()]; $options = []; foreach (ModerationState::loadMultiple() as $moderation_state) { $options[$moderation_state->id()] = $moderation_state->label(); } $form['container'] = ['#type' => 'container', '#attributes' => ['class' => ['container-inline']]]; $form['container']['stateFrom'] = ['#type' => 'select', '#title' => $this->t('Transition from'), '#options' => $options, '#required' => TRUE, '#empty_option' => $this->t('-- Select --'), '#default_value' => $moderation_state_transition->getFromState()]; $form['container']['stateTo'] = ['#type' => 'select', '#options' => $options, '#required' => TRUE, '#title' => $this->t('Transition to'), '#empty_option' => $this->t('-- Select --'), '#default_value' => $moderation_state_transition->getToState()]; return $form; }