Commit cf0bc9a2 authored by catch's avatar catch
Browse files

Issue #3113020 by alexpott, longwave: Properly deprecate...

Issue #3113020 by alexpott, longwave: Properly deprecate \Drupal\Core\Entity\EntityTypeInterface::isSubclassOf()
parent 26189c6f
......@@ -447,6 +447,7 @@ public function entityClassImplements($interface) {
* {@inheritdoc}
*/
public function isSubclassOf($class) {
@trigger_error(__METHOD__ . '() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use Drupal\Core\Entity\EntityTypeInterface::entityClassImplements() instead. See https://www.drupal.org/node/2842808', E_USER_DEPRECATED);
return $this->entityClassImplements($class);
}
......
......@@ -365,9 +365,11 @@ public function entityClassImplements($interface);
* @return bool
* TRUE if the entity type is a subclass of the class or interface.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* @deprecated in drupal:8.3.0 and is removed from drupal:10.0.0.
* Use Drupal\Core\Entity\EntityTypeInterface::entityClassImplements()
* instead.
*
* @see https://www.drupal.org/node/2842808
*/
public function isSubclassOf($class);
......
......@@ -2,6 +2,8 @@
namespace Drupal\Tests\Core\Entity;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Entity\Entity\EntityFormMode;
use Drupal\Core\Entity\EntityType;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
......@@ -480,6 +482,26 @@ protected function assertNoPublicProperties(EntityTypeInterface $entity_type) {
$this->assertEmpty($reflection->getProperties(\ReflectionProperty::IS_PUBLIC));
}
/**
* @covers ::entityClassImplements
*/
public function testEntityClassImplements() {
$entity_type = $this->setUpEntityType(['class' => EntityFormMode::class]);
$this->assertSame(TRUE, $entity_type->entityClassImplements(ConfigEntityInterface::class));
$this->assertSame(FALSE, $entity_type->entityClassImplements(\DateTimeInterface::class));
}
/**
* @covers ::isSubclassOf
* @group legacy
* @expectedDeprecation Drupal\Core\Entity\EntityType::isSubclassOf() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use Drupal\Core\Entity\EntityTypeInterface::entityClassImplements() instead. See https://www.drupal.org/node/2842808
*/
public function testIsSubClassOf() {
$entity_type = $this->setUpEntityType(['class' => EntityFormMode::class]);
$this->assertSame(TRUE, $entity_type->isSubclassOf(ConfigEntityInterface::class));
$this->assertSame(FALSE, $entity_type->isSubclassOf(\DateTimeInterface::class));
}
/**
* Tests that the EntityType object can be serialized.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment