Skip to content
Snippets Groups Projects
Commit d21afb80 authored by catch's avatar catch
Browse files

Issue #3093132 by Sam152, Dinesh18: Remove isLatestRevision,...

Issue #3093132 by Sam152, Dinesh18: Remove isLatestRevision, getLatestRevision, getLatestRevisionId from the ModerationInformation service
parent 35bbac2b
Branches
Tags
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards
...@@ -82,27 +82,6 @@ public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type, ...@@ -82,27 +82,6 @@ public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type,
return FALSE; return FALSE;
} }
/**
* {@inheritdoc}
*/
public function getLatestRevision($entity_type_id, $entity_id) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() and RevisionableStorageInterface::loadRevision() instead. See https://www.drupal.org/node/3087295', E_USER_DEPRECATED);
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
$storage = $this->entityTypeManager->getStorage($entity_type_id);
return $storage->loadRevision($storage->getLatestRevisionId($entity_id));
}
/**
* {@inheritdoc}
*/
public function getLatestRevisionId($entity_type_id, $entity_id) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() instead. See https://www.drupal.org/node/3087295', E_USER_DEPRECATED);
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
if ($storage = $this->entityTypeManager->getStorage($entity_type_id)) {
return $storage->getLatestRevisionId($entity_id);
}
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -133,14 +112,6 @@ public function getAffectedRevisionTranslation(ContentEntityInterface $entity) { ...@@ -133,14 +112,6 @@ public function getAffectedRevisionTranslation(ContentEntityInterface $entity) {
} }
} }
/**
* {@inheritdoc}
*/
public function isLatestRevision(ContentEntityInterface $entity) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableInterface::isLatestRevision() instead. See https://www.drupal.org/node/3087295', E_USER_DEPRECATED);
return $entity->isLatestRevision();
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -58,45 +58,6 @@ public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type, ...@@ -58,45 +58,6 @@ public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type,
*/ */
public function isModeratedEntityType(EntityTypeInterface $entity_type); public function isModeratedEntityType(EntityTypeInterface $entity_type);
/**
* Loads the latest revision of a specific entity.
*
* @param string $entity_type_id
* The entity type ID.
* @param int $entity_id
* The entity ID.
*
* @return \Drupal\Core\Entity\ContentEntityInterface|null
* The latest entity revision or NULL, if the entity type / entity doesn't
* exist.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* RevisionableStorageInterface::getLatestRevisionId and
* RevisionableStorageInterface::loadRevision instead.
*
* @see https://www.drupal.org/node/3087295
*/
public function getLatestRevision($entity_type_id, $entity_id);
/**
* Returns the revision ID of the latest revision of the given entity.
*
* @param string $entity_type_id
* The entity type ID.
* @param int $entity_id
* The entity ID.
*
* @return int
* The revision ID of the latest revision for the specified entity, or
* NULL if there is no such entity.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* RevisionableStorageInterface::getLatestRevisionId instead.
*
* @see https://www.drupal.org/node/3087295
*/
public function getLatestRevisionId($entity_type_id, $entity_id);
/** /**
* Returns the revision ID of the default revision for the specified entity. * Returns the revision ID of the default revision for the specified entity.
* *
...@@ -122,23 +83,6 @@ public function getDefaultRevisionId($entity_type_id, $entity_id); ...@@ -122,23 +83,6 @@ public function getDefaultRevisionId($entity_type_id, $entity_id);
*/ */
public function getAffectedRevisionTranslation(ContentEntityInterface $entity); public function getAffectedRevisionTranslation(ContentEntityInterface $entity);
/**
* Determines if an entity is a latest revision.
*
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* A revisionable content entity.
*
* @return bool
* TRUE if the specified object is the latest revision of its entity,
* FALSE otherwise.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* RevisionableInterface::isLatestRevision instead.
*
* @see https://www.drupal.org/node/3087295
*/
public function isLatestRevision(ContentEntityInterface $entity);
/** /**
* Determines if a pending revision exists for the specified entity. * Determines if a pending revision exists for the specified entity.
* *
......
...@@ -78,70 +78,6 @@ public function testGetDefaultRevisionId() { ...@@ -78,70 +78,6 @@ public function testGetDefaultRevisionId() {
$this->assertSame(1, $default_revision_id); $this->assertSame(1, $default_revision_id);
} }
/**
* @covers ::getLatestRevisionId
* @group legacy
* @expectedDeprecation Drupal\content_moderation\ModerationInformation::getLatestRevisionId is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() instead. See https://www.drupal.org/node/3087295
*/
public function testGetLatestRevisionId() {
$entity_test_rev = EntityTestRev::create([
'name' => 'Default Revision',
'moderation_state' => 'published',
]);
$entity_test_rev->save();
$entity_test_rev->name = 'Pending revision';
$entity_test_rev->moderation_state = 'draft';
$entity_test_rev->save();
// Check that moderation information service returns the correct latest
// revision ID.
$latest_revision_id = $this->moderationInformation->getLatestRevisionId('entity_test_rev', $entity_test_rev->id());
$this->assertSame(2, $latest_revision_id);
}
/**
* @covers ::getLatestRevision
* @group legacy
* @expectedDeprecation Drupal\content_moderation\ModerationInformation::getLatestRevision is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() and RevisionableStorageInterface::loadRevision() instead. See https://www.drupal.org/node/3087295
*/
public function testGetLatestRevision() {
$entity_test_rev = EntityTestRev::create([
'name' => 'Default Revision',
'moderation_state' => 'published',
]);
$entity_test_rev->save();
$entity_test_rev->name = 'Pending revision';
$entity_test_rev->moderation_state = 'draft';
$entity_test_rev->save();
$latest_revision = $this->moderationInformation->getLatestRevision('entity_test_rev', $entity_test_rev->id());
$this->assertEquals(2, $latest_revision->getRevisionId());
}
/**
* @covers ::isLatestRevision
* @group legacy
* @expectedDeprecation Drupal\content_moderation\ModerationInformation::isLatestRevision is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableInterface::isLatestRevision() instead. See https://www.drupal.org/node/3087295
*/
public function testIsLatestRevision() {
$entity_test_rev = EntityTestRev::create([
'name' => 'Default Revision',
'moderation_state' => 'published',
]);
$entity_test_rev->save();
$old_revision = clone $entity_test_rev;
$entity_test_rev->name = 'Pending revision';
$entity_test_rev->moderation_state = 'draft';
$entity_test_rev->save();
$this->assertFalse($this->moderationInformation->isLatestRevision($old_revision));
$this->assertTrue($this->moderationInformation->isLatestRevision($entity_test_rev));
}
/** /**
* @covers ::isDefaultRevisionPublished * @covers ::isDefaultRevisionPublished
* @dataProvider isDefaultRevisionPublishedTestCases * @dataProvider isDefaultRevisionPublishedTestCases
......
...@@ -84,24 +84,4 @@ public function testGetDefaultRevisionId() { ...@@ -84,24 +84,4 @@ public function testGetDefaultRevisionId() {
$this->assertEquals($node->getRevisionId(), $this->moderationInformation->getDefaultRevisionId('node', $node->id())); $this->assertEquals($node->getRevisionId(), $this->moderationInformation->getDefaultRevisionId('node', $node->id()));
} }
/**
* @covers \Drupal\content_moderation\ModerationInformation::getLatestRevisionId
* @group legacy
* @expectedDeprecation Drupal\content_moderation\ModerationInformation::getLatestRevisionId is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() instead. See https://www.drupal.org/node/3087295
*/
public function testGetLatestRevisionId() {
// Create an admin user.
$user = $this->createUser([], NULL, TRUE);
\Drupal::currentUser()->setAccount($user);
// Create a node.
$node = $this->createNode(['type' => 'page']);
$this->assertEquals($node->getRevisionId(), $this->moderationInformation->getLatestRevisionId('node', $node->id()));
// Create a non-admin user.
$user = $this->createUser();
\Drupal::currentUser()->setAccount($user);
$this->assertEquals($node->getRevisionId(), $this->moderationInformation->getLatestRevisionId('node', $node->id()));
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment