diff --git a/core/modules/content_moderation/content_moderation.module b/core/modules/content_moderation/content_moderation.module index 3a7582d..879f381 100644 --- a/core/modules/content_moderation/content_moderation.module +++ b/core/modules/content_moderation/content_moderation.module @@ -3,10 +3,6 @@ /** * @file * Contains content_moderation.module. - * - * @todo include UI bits of https://www.drupal.org/node/2429153 - * @todo How to remove the live version (i.e. published => draft without new - * revision) - i.e. unpublish */ use Drupal\content_moderation\EntityOperations; @@ -35,7 +31,7 @@ function content_moderation_help($route_name, RouteMatchInterface $route_match) case 'help.page.content_moderation': $output = ''; $output .= '

' . t('About') . '

'; - $output .= '

' . t('The Content Moderation module provides basic moderation for content. For more information, see the online documentation for the Content Moderation module.', array(':content_moderation' => 'https://www.drupal.org/documentation/modules/workbench_moderation/')) . '

'; + $output .= '

' . t('The Content Moderation module provides basic moderation for content.') . '

'; return $output; } } diff --git a/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php b/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php new file mode 100644 index 0000000..19ec324 --- /dev/null +++ b/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php @@ -0,0 +1,29 @@ + array('content_entity_type_id', 'content_entity_id', 'content_entity_revision_id'), + ); + + return $schema; + } + +} diff --git a/core/modules/content_moderation/src/Entity/ContentModerationState.php b/core/modules/content_moderation/src/Entity/ContentModerationState.php index bdbba21..bd5e5a8 100644 --- a/core/modules/content_moderation/src/Entity/ContentModerationState.php +++ b/core/modules/content_moderation/src/Entity/ContentModerationState.php @@ -23,6 +23,7 @@ * plural = "@count content moderation states" * ), * handlers = { + * "storage_schema" = "Drupal\content_moderation\ContentModerationStateStorageSchema", * "views_data" = "\Drupal\views\EntityViewsData", * }, * base_table = "content_moderation_state", diff --git a/core/modules/content_moderation/src/EntityOperations.php b/core/modules/content_moderation/src/EntityOperations.php index aee7991..618fda8 100644 --- a/core/modules/content_moderation/src/EntityOperations.php +++ b/core/modules/content_moderation/src/EntityOperations.php @@ -3,7 +3,6 @@ namespace Drupal\content_moderation; use Drupal\content_moderation\Entity\ContentModerationState; -use Drupal\content_moderation\Entity\ModerationState; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityInterface; @@ -101,7 +100,9 @@ public function entityPresave(EntityInterface $entity) { return; } if ($entity->moderation_state->target_id) { - $moderation_state = ModerationState::load($entity->moderation_state->target_id); + $moderation_state = $this->entityTypeManager + ->getStorage('moderation_state') + ->load($entity->moderation_state->target_id); $published_state = $moderation_state->isPublishedState(); // This entity is default if it is new, the default revision, or the @@ -168,18 +169,16 @@ protected function updateOrCreateFromEntity(EntityInterface $entity) { $entity_revision_id = $entity->getRevisionId(); $entity_langcode = $entity->language()->getId(); - // @todo maybe just try and get it from the computed field? - $entities = $this->entityTypeManager - ->getStorage('content_moderation_state') - ->loadByProperties([ - 'content_entity_type_id' => $entity_type_id, - 'content_entity_id' => $entity_id, - ]); + $storage = $this->entityTypeManager->getStorage('content_moderation_state'); + $entities = $storage->loadByProperties([ + 'content_entity_type_id' => $entity_type_id, + 'content_entity_id' => $entity_id, + ]); /** @var \Drupal\content_moderation\ContentModerationStateInterface $content_moderation_state */ $content_moderation_state = reset($entities); if (!($content_moderation_state instanceof ContentModerationStateInterface)) { - $content_moderation_state = ContentModerationState::create([ + $content_moderation_state = $storage->create([ 'content_entity_type_id' => $entity_type_id, 'content_entity_id' => $entity_id, ]); diff --git a/core/modules/content_moderation/src/EntityTypeInfo.php b/core/modules/content_moderation/src/EntityTypeInfo.php index 95a1be4..f3a3ea5 100644 --- a/core/modules/content_moderation/src/EntityTypeInfo.php +++ b/core/modules/content_moderation/src/EntityTypeInfo.php @@ -275,8 +275,6 @@ public function entityBaseFieldInfo(EntityTypeInterface $entity_type) { 'type' => 'hidden', 'weight' => -5, ]) - // @todo write a custom widget/selection handler plugin instead of - // manual filtering? ->setDisplayOptions('form', [ 'type' => 'moderation_state_default', 'weight' => 5, diff --git a/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php b/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php index 5498ff8..ebcb1ac 100644 --- a/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php +++ b/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php @@ -39,9 +39,8 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} * - * We need to blank out the base form ID so that poorly written form alters - * that use the base form ID to target both add and edit forms don't pick - * up our form. This should be fixed in core. + * Blank out the base form ID so that form alters that use the base form ID to + * target both add and edit forms don't pick up this form. */ public function getBaseFormId() { return NULL; @@ -114,9 +113,9 @@ public function form(array $form, FormStateInterface $form_state) { ], ]; - // This is screwy, but the key of the array needs to be a user-facing string - // so we have to fully render the translatable string to a real string, or - // else PHP chokes on an object used as an array key. + // The key of the array needs to be a user-facing string so we have to fully + // render the translatable string to a real string, or else PHP errors on an + // object used as an array key. $options = [ $this->t('Unpublished')->render() => $options_unpublished, $this->t('Published')->render() => $options_published, diff --git a/core/modules/content_moderation/src/ModerationInformation.php b/core/modules/content_moderation/src/ModerationInformation.php index 2c2c8a9..07d4022 100644 --- a/core/modules/content_moderation/src/ModerationInformation.php +++ b/core/modules/content_moderation/src/ModerationInformation.php @@ -129,9 +129,6 @@ public function isModeratedEntityForm(FormInterface $form_object) { * {@inheritdoc} */ public function isRevisionableBundleForm(FormInterface $form_object) { - // We really shouldn't be checking for a base class, but core lacks an - // interface here. When core adds a better way to determine if we're on - // a Bundle configuration form we should switch to that. if ($form_object instanceof BundleEntityFormBase) { $bundle_of = $form_object->getEntity()->getEntityType()->getBundleOf(); $type = $this->entityTypeManager->getDefinition($bundle_of); diff --git a/core/modules/content_moderation/tests/modules/content_moderation_test_views/content_moderation_test_views.info.yml b/core/modules/content_moderation/tests/modules/content_moderation_test_views/content_moderation_test_views.info.yml index 44b68d4..b96ef84 100644 --- a/core/modules/content_moderation/tests/modules/content_moderation_test_views/content_moderation_test_views.info.yml +++ b/core/modules/content_moderation/tests/modules/content_moderation_test_views/content_moderation_test_views.info.yml @@ -7,4 +7,4 @@ core: 8.x dependencies: - content_moderation - node - - views \ No newline at end of file + - views