diff --git a/core/modules/content_moderation/content_moderation.module b/core/modules/content_moderation/content_moderation.module index 06e4279..07a4bb5 100644 --- a/core/modules/content_moderation/content_moderation.module +++ b/core/modules/content_moderation/content_moderation.module @@ -179,7 +179,7 @@ function content_moderation_node_access(NodeInterface $node, $operation, Account $access_result->addCacheableDependency($node); } - elseif ($operation === 'update' && $moderation_info->isModeratedEntity($node) && $node->moderation_state && $node->moderation_state->target_id) { + elseif ($operation === 'update' && $moderation_info->isModeratableEntity($node) && $node->moderation_state && $node->moderation_state->target_id) { /** @var \Drupal\content_moderation\StateTransitionValidation $transition_validation */ $transition_validation = \Drupal::service('content_moderation.state_transition_validation'); diff --git a/core/modules/content_moderation/src/Entity/ContentModerationState.php b/core/modules/content_moderation/src/Entity/ContentModerationState.php index bd5e5a8..1ff7f2a 100644 --- a/core/modules/content_moderation/src/Entity/ContentModerationState.php +++ b/core/modules/content_moderation/src/Entity/ContentModerationState.php @@ -79,8 +79,9 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setRequired(TRUE) ->setRevisionable(TRUE); - // @todo Add constraint that enforces unique content_entity_type_id / content_entity_id - // @todo Index on content_entity_type_id, content_entity_id and content_entity_revision_id + // @todo https://www.drupal.org/node/2779931 Add constraint that enforces + // unique content_entity_type_id, content_entity_id and + // content_entity_revision_id. $fields['content_entity_revision_id'] = BaseFieldDefinition::create('integer') ->setLabel(t('Content entity revision ID')) diff --git a/core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php b/core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php index f2835e4..9d89253 100644 --- a/core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php +++ b/core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php @@ -30,8 +30,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * {@inheritdoc} */ public function onPresave(ContentEntityInterface $entity, $default_revision, $published_state) { - // This is *probably* not necessary if configuration is setup correctly, - // but it can't hurt. + // This is probably not necessary if configuration is setup correctly. $entity->setNewRevision(TRUE); $entity->isDefaultRevision($default_revision); } @@ -41,10 +40,10 @@ public function onPresave(ContentEntityInterface $entity, $default_revision, $pu */ public function onBundleModerationConfigurationFormSubmit(ConfigEntityInterface $bundle) { // The Revisions portion of Entity API is not uniformly applied or - // consistent. Until that's fixed in core, we'll make a best-attempt to - // apply it to the common entity patterns so as to avoid every entity type - // needing to implement this method, although some will still need to do so - // for now. This is the API that should be universal, but isn't yet. + // consistent. Until that's fixed, we'll make a best-attempt to apply it to + // the common entity patterns so as to avoid every entity type needing to + // implement this method, although some will still need to do so for now. + // This is the API that should be universal, but isn't yet. // @see \Drupal\node\Entity\NodeType if (method_exists($bundle, 'setNewRevision')) { $bundle->setNewRevision(TRUE); diff --git a/core/modules/content_moderation/src/Entity/Handler/ModerationHandlerInterface.php b/core/modules/content_moderation/src/Entity/Handler/ModerationHandlerInterface.php index c3d6ddd..e897cf4 100644 --- a/core/modules/content_moderation/src/Entity/Handler/ModerationHandlerInterface.php +++ b/core/modules/content_moderation/src/Entity/Handler/ModerationHandlerInterface.php @@ -16,7 +16,7 @@ interface ModerationHandlerInterface { /** - * Operates on moderated content entities preSave(). + * Operates on moderatable content entities preSave(). * * @param \Drupal\Core\Entity\ContentEntityInterface $entity * The entity to modify. @@ -28,7 +28,7 @@ public function onPresave(ContentEntityInterface $entity, $default_revision, $published_state); /** - * Operates on the bundle definition that has been marked as moderated. + * Operates on the bundle definition that has been marked as moderatable. * * Note: The values on the EntityModerationForm itself are already saved * so do not need to be saved here. If any changes are made to the bundle diff --git a/core/modules/content_moderation/src/EntityOperations.php b/core/modules/content_moderation/src/EntityOperations.php index 584b4e5..618fda8 100644 --- a/core/modules/content_moderation/src/EntityOperations.php +++ b/core/modules/content_moderation/src/EntityOperations.php @@ -96,7 +96,7 @@ protected function getDefaultLoadStateId(ContentEntityInterface $entity) { * The entity being saved. */ public function entityPresave(EntityInterface $entity) { - if (!$this->moderationInfo->isModeratedEntity($entity)) { + if (!$this->moderationInfo->isModeratableEntity($entity)) { return; } if ($entity->moderation_state->target_id) { @@ -125,10 +125,11 @@ public function entityPresave(EntityInterface $entity) { * @see hook_entity_insert() */ public function entityInsert(EntityInterface $entity) { - if ($this->moderationInfo->isModeratedEntity($entity)) { - $this->updateOrCreateFromEntity($entity); - $this->setLatestRevision($entity); + if (!$this->moderationInfo->isModeratableEntity($entity)) { + return; } + $this->updateOrCreateFromEntity($entity); + $this->setLatestRevision($entity); } /** @@ -140,10 +141,11 @@ public function entityInsert(EntityInterface $entity) { * @see hook_entity_update() */ public function entityUpdate(EntityInterface $entity) { - if ($this->moderationInfo->isModeratedEntity($entity)) { - $this->updateOrCreateFromEntity($entity); - $this->setLatestRevision($entity); + if (!$this->moderationInfo->isModeratableEntity($entity)) { + return; } + $this->updateOrCreateFromEntity($entity); + $this->setLatestRevision($entity); } /** @@ -225,7 +227,7 @@ protected function setLatestRevision(EntityInterface $entity) { * @see EntityFieldManagerInterface::getExtraFields() */ public function entityView(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { - if (!$this->moderationInfo->isModeratedEntity($entity)) { + if (!$this->moderationInfo->isModeratableEntity($entity)) { return; } if (!$this->moderationInfo->isLatestRevision($entity)) { diff --git a/core/modules/content_moderation/src/EntityTypeInfo.php b/core/modules/content_moderation/src/EntityTypeInfo.php index d6e7c09..64c7946 100644 --- a/core/modules/content_moderation/src/EntityTypeInfo.php +++ b/core/modules/content_moderation/src/EntityTypeInfo.php @@ -170,7 +170,7 @@ public function entityOperation(EntityInterface $entity) { $operations = []; $type = $entity->getEntityType(); - if ($this->moderationInfo->isBundleForModeratedEntity($entity)) { + if ($this->moderationInfo->isBundleForModeratableEntity($entity)) { $operations['manage-moderation'] = [ 'title' => t('Manage moderation'), 'weight' => 27, @@ -259,7 +259,7 @@ protected function getModeratedBundles() { * New fields added by moderation state. */ public function entityBaseFieldInfo(EntityTypeInterface $entity_type) { - if (!$this->moderationInfo->isModeratedEntityType($entity_type)) { + if (!$this->moderationInfo->isModeratableEntityType($entity_type)) { return []; } @@ -289,7 +289,7 @@ public function entityBaseFieldInfo(EntityTypeInterface $entity_type) { } /** - * Adds the ModerationState constraint to bundles that are moderated. + * Adds the ModerationState constraint to bundles that are moderatable. * * @param \Drupal\Core\Field\FieldDefinitionInterface[] $fields * The array of bundle field definitions. @@ -301,7 +301,7 @@ public function entityBaseFieldInfo(EntityTypeInterface $entity_type) { * @see hook_entity_bundle_field_info_alter(); */ public function entityBundleFieldInfoAlter(&$fields, EntityTypeInterface $entity_type, $bundle) { - if (!empty($fields['moderation_state']) && $this->moderationInfo->isModeratedBundle($entity_type, $bundle)) { + if (!empty($fields['moderation_state']) && $this->moderationInfo->isModeratableBundle($entity_type, $bundle)) { $fields['moderation_state']->addConstraint('ModerationState', []); } } diff --git a/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php b/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php index ebcb1ac..58dd334 100644 --- a/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php +++ b/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php @@ -153,7 +153,7 @@ public function form(array $form, FormStateInterface $form_state) { * The current state of the form. */ public function formBuilderCallback($entity_type_id, EntityInterface $bundle, &$form, FormStateInterface $form_state) { - // @todo write a test for this. + // @todo https://www.drupal.org/node/2779933 write a test for this. if ($bundle instanceof ThirdPartySettingsInterface) { $bundle->setThirdPartySetting('content_moderation', 'enabled', $form_state->getValue('enable_moderation_state')); $bundle->setThirdPartySetting('content_moderation', 'allowed_moderation_states', array_keys(array_filter($form_state->getValue('allowed_moderation_states_published') + $form_state->getValue('allowed_moderation_states_unpublished')))); diff --git a/core/modules/content_moderation/src/ModerationInformation.php b/core/modules/content_moderation/src/ModerationInformation.php index f9e726c..cf79bc1 100644 --- a/core/modules/content_moderation/src/ModerationInformation.php +++ b/core/modules/content_moderation/src/ModerationInformation.php @@ -48,18 +48,18 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Acc /** * {@inheritdoc} */ - public function isModeratedEntity(EntityInterface $entity) { + public function isModeratableEntity(EntityInterface $entity) { if (!$entity instanceof ContentEntityInterface) { return FALSE; } - return $this->isModeratedBundle($entity->getEntityType(), $entity->bundle()); + return $this->isModeratableBundle($entity->getEntityType(), $entity->bundle()); } /** * {@inheritdoc} */ - public function isModeratedEntityType(EntityTypeInterface $entity_type) { + public function isModeratableEntityType(EntityTypeInterface $entity_type) { return $entity_type->hasHandlerClass('moderation'); } @@ -75,7 +75,7 @@ public function loadBundleEntity($bundle_entity_type_id, $bundle_id) { /** * {@inheritdoc} */ - public function isModeratedBundle(EntityTypeInterface $entity_type, $bundle) { + public function isModeratableBundle(EntityTypeInterface $entity_type, $bundle) { if ($bundle_entity = $this->loadBundleEntity($entity_type->getBundleEntityType(), $bundle)) { return $bundle_entity->getThirdPartySetting('content_moderation', 'enabled', FALSE); } @@ -107,7 +107,7 @@ public function selectRevisionableEntities(array $entity_types) { /** * {@inheritdoc} */ - public function isBundleForModeratedEntity(EntityInterface $entity) { + public function isBundleForModeratableEntity(EntityInterface $entity) { $type = $entity->getEntityType(); return @@ -122,7 +122,7 @@ public function isBundleForModeratedEntity(EntityInterface $entity) { */ public function isModeratedEntityForm(FormInterface $form_object) { return $form_object instanceof ContentEntityFormInterface - && $this->isModeratedEntity($form_object->getEntity()); + && $this->isModeratableEntity($form_object->getEntity()); } /** @@ -191,7 +191,7 @@ public function isLatestRevision(ContentEntityInterface $entity) { * {@inheritdoc} */ public function hasForwardRevision(ContentEntityInterface $entity) { - return $this->isModeratedEntity($entity) + return $this->isModeratableEntity($entity) && !($this->getLatestRevisionId($entity->getEntityTypeId(), $entity->id()) == $this->getDefaultRevisionId($entity->getEntityTypeId(), $entity->id())); } diff --git a/core/modules/content_moderation/src/ModerationInformationInterface.php b/core/modules/content_moderation/src/ModerationInformationInterface.php index 6e2d3fa..b203792 100644 --- a/core/modules/content_moderation/src/ModerationInformationInterface.php +++ b/core/modules/content_moderation/src/ModerationInformationInterface.php @@ -26,29 +26,29 @@ public function loadBundleEntity($bundle_entity_type_id, $bundle_id); /** - * Determines if an entity is moderated. + * Determines if an entity is one we should be moderating. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity we may be moderating. * * @return bool - * TRUE if this is an entity tis moderated, FALSE otherwise. + * TRUE if this is an entity that we should act upon, FALSE otherwise. */ - public function isModeratedEntity(EntityInterface $entity); + public function isModeratableEntity(EntityInterface $entity); /** - * Determines if an entity type is moderated. + * Determines if an entity type has been marked as moderatable. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * An entity type object. * * @return bool - * TRUE if this entity type is moderated, FALSE otherwise. + * TRUE if this entity type has been marked as moderatable, FALSE otherwise. */ - public function isModeratedEntityType(EntityTypeInterface $entity_type); + public function isModeratableEntityType(EntityTypeInterface $entity_type); /** - * Determines if an entity type/bundle is moderated. + * Determines if an entity type/bundle is one that will be moderated. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type definition to check. @@ -56,9 +56,9 @@ public function isModeratedEntityType(EntityTypeInterface $entity_type); * The bundle to check. * * @return bool - * TRUE if this is a bundle is moderated, FALSE otherwise. + * TRUE if this is a bundle we want to moderate, FALSE otherwise. */ - public function isModeratedBundle(EntityTypeInterface $entity_type, $bundle); + public function isModeratableBundle(EntityTypeInterface $entity_type, $bundle); /** * Filters entity lists to just bundle definitions for revisionable entities. @@ -72,16 +72,16 @@ public function isModeratedBundle(EntityTypeInterface $entity_type, $bundle); public function selectRevisionableEntityTypes(array $entity_types); /** - * Filters entity lists to just the definitions that can be moderated. + * Filters entity lists to just the definitions for moderatable entities. * - * An entity type can be moderated only if it is both revisionable and + * An entity type is moderatable only if it is both revisionable and * bundleable. * * @param EntityTypeInterface[] $entity_types * The master entity type list filter. * * @return \Drupal\Core\Entity\ContentEntityTypeInterface[] - * An array of only the content entity definitions that can be moderated. + * An array of only the content entity definitions we want to modify. */ public function selectRevisionableEntities(array $entity_types); @@ -101,7 +101,7 @@ public function selectRevisionableEntities(array $entity_types); * TRUE if we want to add a Moderation operation to this entity, FALSE * otherwise. */ - public function isBundleForModeratedEntity(EntityInterface $entity); + public function isBundleForModeratableEntity(EntityInterface $entity); /** * Determines if this form is for a moderated entity. diff --git a/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php b/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php index 980c61e..263183b 100644 --- a/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php +++ b/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php @@ -88,7 +88,7 @@ protected function isEditFormPage(Route $route) { public function convert($value, $definition, $name, array $defaults) { $entity = parent::convert($value, $definition, $name, $defaults); - if ($entity && $this->moderationInformation->isModeratedEntity($entity) && !$this->moderationInformation->isLatestRevision($entity)) { + if ($entity && $this->moderationInformation->isModeratableEntity($entity) && !$this->moderationInformation->isLatestRevision($entity)) { $entity_type_id = $this->getEntityTypeFromDefaults($definition, $name, $defaults); $latest_revision = $this->moderationInformation->getLatestRevision($entity_type_id, $value); diff --git a/core/modules/content_moderation/src/Permissions.php b/core/modules/content_moderation/src/Permissions.php index f23ccc7..027684c 100644 --- a/core/modules/content_moderation/src/Permissions.php +++ b/core/modules/content_moderation/src/Permissions.php @@ -20,7 +20,7 @@ class Permissions { * The transition permissions. */ public function transitionPermissions() { - // @todo write a test for this. + // @todo https://www.drupal.org/node/2779933 write a test for this. $perms = []; /* @var \Drupal\content_moderation\ModerationStateInterface[] $states */ $states = ModerationState::loadMultiple(); diff --git a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublishNode.php b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublishNode.php index e3563ae..a85bac6 100644 --- a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublishNode.php +++ b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublishNode.php @@ -54,7 +54,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function execute($entity = NULL) { - if ($entity && $this->moderationInfo->isModeratedEntity($entity)) { + if ($entity && $this->moderationInfo->isModeratableEntity($entity)) { drupal_set_message($this->t('One or more entities were skipped as they are under moderation and may not be directly published or unpublished.')); return; } @@ -67,7 +67,7 @@ public function execute($entity = NULL) { */ public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { $result = parent::access($object, $account, TRUE) - ->andif(AccessResult::forbiddenIf($this->moderationInfo->isModeratedEntity($object))->addCacheableDependency($object)); + ->andif(AccessResult::forbiddenIf($this->moderationInfo->isModeratableEntity($object))->addCacheableDependency($object)); return $return_as_object ? $result : $result->isAllowed(); } diff --git a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublishNode.php b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublishNode.php index 28b9689..b0fbd87 100644 --- a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublishNode.php +++ b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublishNode.php @@ -54,7 +54,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function execute($entity = NULL) { - if ($entity && $this->moderationInfo->isModeratedEntity($entity)) { + if ($entity && $this->moderationInfo->isModeratableEntity($entity)) { drupal_set_message($this->t('One or more entities were skipped as they are under moderation and may not be directly published or unpublished.')); return; } @@ -67,7 +67,7 @@ public function execute($entity = NULL) { */ public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { $result = parent::access($object, $account, TRUE) - ->andif(AccessResult::forbiddenIf($this->moderationInfo->isModeratedEntity($object))->addCacheableDependency($object)); + ->andif(AccessResult::forbiddenIf($this->moderationInfo->isModeratableEntity($object))->addCacheableDependency($object)); return $return_as_object ? $result : $result->isAllowed(); } diff --git a/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php b/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php index d8f0bf5..39bfe0d 100644 --- a/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php +++ b/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php @@ -76,7 +76,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = []; - foreach ($this->moderatedEntityTypeDefinitions() as $entity_type_id => $entity_type) { + foreach ($this->moderatableEntityTypeDefinitions() as $entity_type_id => $entity_type) { $this->derivatives["$entity_type_id.moderation_tab"] = [ 'route_name' => "entity.$entity_type_id.moderation", 'title' => $this->t('Manage moderation'), @@ -86,7 +86,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { ] + $base_plugin_definition; } - $latest_version_entities = array_filter($this->moderatedEntityDefinitions(), function (EntityTypeInterface $type) { + $latest_version_entities = array_filter($this->moderatableEntityDefinitions(), function (EntityTypeInterface $type) { return $type->hasLinkTemplate('latest-version'); }); @@ -103,12 +103,12 @@ public function getDerivativeDefinitions($base_plugin_definition) { } /** - * Returns an array of content entities that are potentially moderated. + * Returns an array of content entities that are potentially moderatable. * * @return EntityTypeInterface[] * An array of just those entities we care about. */ - protected function moderatedEntityDefinitions() { + protected function moderatableEntityDefinitions() { return $this->moderationInfo->selectRevisionableEntities($this->entityTypeManager->getDefinitions()); } @@ -118,7 +118,7 @@ protected function moderatedEntityDefinitions() { * @return EntityTypeInterface[] * An array of entity types that represent bundles that can be moderated. */ - protected function moderatedEntityTypeDefinitions() { + protected function moderatableEntityTypeDefinitions() { return $this->moderationInfo->selectRevisionableEntityTypes($this->entityTypeManager->getDefinitions()); } 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 7f6c32a..75f3d81 100644 --- a/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php +++ b/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php @@ -146,8 +146,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /* @var \Drupal\Core\Config\Entity\ConfigEntityInterface $bundle_entity */ $bundle_entity = $this->entityTypeManager->getStorage($entity->getEntityType()->getBundleEntityType())->load($entity->bundle()); - if (!$this->moderationInformation->isModeratedEntity($entity)) { - // @todo write a test for this. + if (!$this->moderationInformation->isModeratableEntity($entity)) { + // @todo https://www.drupal.org/node/2779933 write a test for this. return $element + ['#access' => FALSE]; } @@ -166,7 +166,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $target_states[$transition->getToState()] = $transition->label(); } - // @todo write a test for this. + // @todo https://www.drupal.org/node/2779933 write a test for this. $element += [ '#access' => FALSE, '#type' => 'select', diff --git a/core/modules/content_moderation/src/Plugin/Menu/EditTab.php b/core/modules/content_moderation/src/Plugin/Menu/EditTab.php index c424a01..b8ccc2d 100644 --- a/core/modules/content_moderation/src/Plugin/Menu/EditTab.php +++ b/core/modules/content_moderation/src/Plugin/Menu/EditTab.php @@ -78,12 +78,12 @@ public function getRouteParameters(RouteMatchInterface $route_match) { * {@inheritdoc} */ public function getTitle() { - if (!$this->moderationInfo->isModeratedEntity($this->entity)) { + if (!$this->moderationInfo->isModeratableEntity($this->entity)) { // Moderation isn't enabled. return parent::getTitle(); } - // @todo write a test for this. + // @todo https://www.drupal.org/node/2779933 write a test for this. return $this->moderationInfo->isLiveRevision($this->entity) ? $this->t('New draft') : $this->t('Edit draft'); @@ -93,7 +93,7 @@ public function getTitle() { * {@inheritdoc} */ public function getCacheTags() { - // @todo write a test for this. + // @todo https://www.drupal.org/node/2779933 write a test for this. $tags = parent::getCacheTags(); // Tab changes if node or node-type is modified. $tags = array_merge($tags, $this->entity->getCacheTags()); diff --git a/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php b/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php index f70537c..b401b81 100644 --- a/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php +++ b/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php @@ -73,7 +73,7 @@ public function validate($value, Constraint $constraint) { $entity = $value->getEntity(); // Ignore entities that are not subject to moderation anyway. - if (!$this->moderationInformation->isModeratedEntity($entity)) { + if (!$this->moderationInformation->isModeratableEntity($entity)) { return; } diff --git a/core/modules/content_moderation/tests/src/Kernel/EntityOperationsTest.php b/core/modules/content_moderation/tests/src/Kernel/EntityOperationsTest.php index 929356e..99d8f0e 100644 --- a/core/modules/content_moderation/tests/src/Kernel/EntityOperationsTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/EntityOperationsTest.php @@ -40,7 +40,7 @@ protected function setUp() { } /** - * Creates a page node type to test with, ensuring that it's moderated. + * Creates a page node type to test with, ensuring that it's moderatable. */ protected function createNodeType() { $node_type = NodeType::create([ diff --git a/core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php b/core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php index 7b02851..6833cdb 100644 --- a/core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php +++ b/core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php @@ -64,9 +64,9 @@ public function setupModerationEntityManager($status) { /** * @dataProvider providerBoolean - * @covers ::isModeratedEntity + * @covers ::isModeratableEntity */ - public function testIsModeratedEntity($status) { + public function testIsModeratableEntity($status) { $moderation_information = new ModerationInformation($this->setupModerationEntityManager($status), $this->getUser()); $entity_type = new ContentEntityType([ @@ -77,13 +77,13 @@ public function testIsModeratedEntity($status) { $entity->getEntityType()->willReturn($entity_type); $entity->bundle()->willReturn('test_bundle'); - $this->assertEquals($status, $moderation_information->isModeratedEntity($entity->reveal())); + $this->assertEquals($status, $moderation_information->isModeratableEntity($entity->reveal())); } /** - * @covers ::isModeratedEntity + * @covers ::isModeratableEntity */ - public function testIsModeratedEntityForNonBundleEntityType() { + public function testIsModeratableEntityForNonBundleEntityType() { $entity_type = new ContentEntityType([ 'id' => 'test_entity_type', ]); @@ -95,14 +95,14 @@ public function testIsModeratedEntityForNonBundleEntityType() { $entity_type_manager = $this->getEntityTypeManager($entity_storage->reveal()); $moderation_information = new ModerationInformation($entity_type_manager, $this->getUser()); - $this->assertEquals(FALSE, $moderation_information->isModeratedEntity($entity->reveal())); + $this->assertEquals(FALSE, $moderation_information->isModeratableEntity($entity->reveal())); } /** * @dataProvider providerBoolean - * @covers ::isModeratedBundle + * @covers ::isModeratableBundle */ - public function testIsModeratedBundle($status) { + public function testIsModeratableBundle($status) { $entity_type = new ContentEntityType([ 'id' => 'test_entity_type', 'bundle_entity_type' => 'entity_test_bundle', @@ -110,7 +110,7 @@ public function testIsModeratedBundle($status) { $moderation_information = new ModerationInformation($this->setupModerationEntityManager($status), $this->getUser()); - $this->assertEquals($status, $moderation_information->isModeratedBundle($entity_type, 'test_bundle')); + $this->assertEquals($status, $moderation_information->isModeratableBundle($entity_type, 'test_bundle')); } /**