diff --git a/core/lib/Drupal/Core/Workflow/Entity/Workflow.php b/core/lib/Drupal/Core/Workflow/Entity/Workflow.php index 762d6b0..c785a10 100644 --- a/core/lib/Drupal/Core/Workflow/Entity/Workflow.php +++ b/core/lib/Drupal/Core/Workflow/Entity/Workflow.php @@ -44,7 +44,7 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface, EntityWithPluginCollectionInterface { /** - * The Moderation state ID. + * The Workflow ID. * * @var string */ @@ -60,8 +60,8 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface, EntityWith /** * The states of the workflow. * - * The array key is the machine for the state. The structure of each array - * item is: + * The array key is the machine name for the state. The structure of each + * array item is: * @code * label: {translatable label} * weight: {integer value} @@ -88,7 +88,7 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface, EntityWith protected $transitions = []; /** - * The workflow type. + * The workflow type plugin ID. * * @see \Drupal\Core\Workflow\WorkflowTypeManager * @@ -97,11 +97,14 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface, EntityWith protected $type; /** + * The configuration for the workflow type plugin. * @var array */ protected $type_settings = []; /** + * The workflow type plugin collection. + * * @var \Drupal\Component\Plugin\LazyPluginCollection */ protected $pluginCollection; diff --git a/core/modules/content_moderation/src/ContentModerationState.php b/core/modules/content_moderation/src/ContentModerationState.php index 7c39353..265a01c 100644 --- a/core/modules/content_moderation/src/ContentModerationState.php +++ b/core/modules/content_moderation/src/ContentModerationState.php @@ -56,7 +56,7 @@ public function __construct(StateInterface $state, $published = FALSE, $default_ * * @return bool */ - public function isPublished() { + public function isPublishedState() { return $this->published; } @@ -65,7 +65,7 @@ public function isPublished() { * * @return bool */ - public function isDefaultRevision() { + public function isDefaultRevisionState() { return $this->defaultRevision; } diff --git a/core/modules/content_moderation/src/EntityOperations.php b/core/modules/content_moderation/src/EntityOperations.php index c910c1d..0fa1dd7 100644 --- a/core/modules/content_moderation/src/EntityOperations.php +++ b/core/modules/content_moderation/src/EntityOperations.php @@ -102,16 +102,17 @@ public function entityPresave(EntityInterface $entity) { if ($entity->moderation_state->value) { $workflow = $this->moderationInfo->getWorkFlowForEntity($entity); - $published_state = $workflow->getState($entity->moderation_state->value)->isPublished(); + /** @var \Drupal\content_moderation\ContentModerationState $current_state */ + $current_state = $workflow->getState($entity->moderation_state->value); // This entity is default if it is new, the default revision, or the // default revision is not published. $update_default_revision = $entity->isNew() - || $workflow->getState($entity->moderation_state->value)->isDefaultRevision() + || $current_state->isDefaultRevisionState() || !$this->isDefaultRevisionPublished($entity, $workflow); // Fire per-entity-type logic for handling the save process. - $this->entityTypeManager->getHandler($entity->getEntityTypeId(), 'moderation')->onPresave($entity, $update_default_revision, $published_state); + $this->entityTypeManager->getHandler($entity->getEntityTypeId(), 'moderation')->onPresave($entity, $update_default_revision, $current_state->isPublishedState()); } } @@ -275,7 +276,7 @@ protected function isDefaultRevisionPublished(EntityInterface $entity, WorkflowI $default_revision = $default_revision->getTranslation($entity->language()->getId()); } - return $default_revision && $workflow->getState($default_revision->moderation_state->value)->isPublished(); + return $default_revision && $workflow->getState($default_revision->moderation_state->value)->isPublishedState(); } } diff --git a/core/modules/content_moderation/src/Form/EntityModerationForm.php b/core/modules/content_moderation/src/Form/EntityModerationForm.php index cdd6dad..132cea6 100644 --- a/core/modules/content_moderation/src/Form/EntityModerationForm.php +++ b/core/modules/content_moderation/src/Form/EntityModerationForm.php @@ -140,7 +140,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // the default state, as we hide that latest-revision tab if there is no // forward revision. Redirect to the canonical URL instead, since that will // still exist. - if ($new_state->isDefaultRevision()) { + if ($new_state->isDefaultRevisionState()) { $form_state->setRedirectUrl($entity->toUrl('canonical')); } } diff --git a/core/modules/content_moderation/src/ModerationInformation.php b/core/modules/content_moderation/src/ModerationInformation.php index c109b31..e8ebf39 100644 --- a/core/modules/content_moderation/src/ModerationInformation.php +++ b/core/modules/content_moderation/src/ModerationInformation.php @@ -134,7 +134,7 @@ public function isLiveRevision(ContentEntityInterface $entity) { return $this->isLatestRevision($entity) && $entity->isDefaultRevision() && $entity->moderation_state->value - && $workflow->getState($entity->moderation_state->value)->isPublished(); + && $workflow->getState($entity->moderation_state->value)->isPublishedState(); } /** diff --git a/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php b/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php index 7eec815..239ab30 100644 --- a/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php +++ b/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php @@ -136,7 +136,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#type' => 'select', '#options' => $target_states, '#default_value' => $default->id(), - '#published' => $default->isPublished(), + '#published' => $default->isPublishedState(), '#key_column' => $this->column, ]; $element['#element_validate'][] = array(get_class($this), 'validateElement'); diff --git a/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php b/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php index 292e952..3db44f1 100644 --- a/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php +++ b/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php @@ -56,14 +56,14 @@ public function buildStateConfigurationForm(FormStateInterface $form_state, Work '#type' => 'checkbox', '#title' => $this->t('Published'), '#description' => $this->t('When content reaches this state it should be published.'), - '#default_value' => isset($state) ? $state->isPublished() : FALSE, + '#default_value' => isset($state) ? $state->isPublishedState() : FALSE, ]; $form['default_revision'] = [ '#type' => 'checkbox', '#title' => $this->t('Default revision'), '#description' => $this->t('When content reaches this state it should be made the default revision; this is implied for published states.'), - '#default_value' => isset($state) ? $state->isDefaultRevision() : FALSE, + '#default_value' => isset($state) ? $state->isDefaultRevisionState() : FALSE, // @todo Add form #state to force "make default" on when "published" is // on for a state. // @see https://www.drupal.org/node/2645614 diff --git a/core/modules/workflow_ui/src/Form/WorkflowAddForm.php b/core/modules/workflow_ui/src/Form/WorkflowAddForm.php index e0d400c..62f3b29 100644 --- a/core/modules/workflow_ui/src/Form/WorkflowAddForm.php +++ b/core/modules/workflow_ui/src/Form/WorkflowAddForm.php @@ -22,7 +22,7 @@ class WorkflowAddForm extends EntityForm { protected $workflowTypePluginManager; /** - * WorkflowEditForm constructor. + * WorkflowAddForm constructor. * * @param \Drupal\Component\Plugin\PluginManagerInterface $workflow_type_plugin_manager * The workflow type plugin manager. diff --git a/core/modules/workflow_ui/src/Form/WorkflowStateAddForm.php b/core/modules/workflow_ui/src/Form/WorkflowStateAddForm.php index e87bf2c..2003a71 100644 --- a/core/modules/workflow_ui/src/Form/WorkflowStateAddForm.php +++ b/core/modules/workflow_ui/src/Form/WorkflowStateAddForm.php @@ -37,7 +37,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['transition_to_self_label'] = [ '#type' => 'textfield', - '#title' => $this->t('Label'), + '#title' => $this->t('Transition to self label'), '#maxlength' => 255, '#default_value' => '', '#description' => $this->t('Label for the transition to self. If this is left blank a transition will not be created.'), diff --git a/core/modules/workflow_ui/src/Form/WorkflowStateEditForm.php b/core/modules/workflow_ui/src/Form/WorkflowStateEditForm.php index eabbc5d..606cdd7 100644 --- a/core/modules/workflow_ui/src/Form/WorkflowStateEditForm.php +++ b/core/modules/workflow_ui/src/Form/WorkflowStateEditForm.php @@ -61,7 +61,7 @@ public function form(array $form, FormStateInterface $form_state) { ]; $header = [ - 'label' => $this->t('Label'), + 'label' => $this->t('Transition'), 'state' => $this->t('To'), 'operations' => $this->t('Operations'), ]; diff --git a/core/modules/workflow_ui/workflow_ui.module b/core/modules/workflow_ui/workflow_ui.module index 1a94ab6..5035ef1 100644 --- a/core/modules/workflow_ui/workflow_ui.module +++ b/core/modules/workflow_ui/workflow_ui.module @@ -24,7 +24,7 @@ function workflow_ui_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { // Main module help for the Workflow UI module. - case 'help.page.workflow': + case 'help.page.workflow_ui': $output = ''; $output .= '
' . t('The Workflow UI module provides a UI for creating workflows content. This lets site admins define workflows and their states, and then define transitions between those states. For more information, see the online documentation for the Workflow UI module.', [':workflow' => 'https://www.drupal.org/documentation/modules/workflow_ui']) . '
';