Commit 3d72d4be authored by catch's avatar catch

Issue #2194783 by Berdir, vprocessor, andypost, Antonnavi, tim.plunkett,...

Issue #2194783 by Berdir, vprocessor, andypost, Antonnavi, tim.plunkett, Crell, Mile23, catch: Rename EntityTypeInterface::isSubclassOf() to ::entityClassImplements()
parent ab8284be
......@@ -366,7 +366,7 @@ public function updateFormLangcode($entity_type_id, EntityInterface $entity, arr
* The entity updated with the submitted values.
*/
public function updateChangedTime(EntityInterface $entity) {
if ($entity->getEntityType()->isSubclassOf(EntityChangedInterface::class)) {
if ($entity instanceof EntityChangedInterface) {
$entity->setChangedTime($this->time->getRequestTime());
}
}
......
......@@ -2,6 +2,7 @@
namespace Drupal\Core\Entity\Controller;
use Drupal\Core\Entity\EntityDescriptionInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
......@@ -307,7 +308,7 @@ protected function doGetEntity(RouteMatchInterface $route_match, EntityInterface
* The expanded array of bundle information.
*/
protected function loadBundleDescriptions(array $bundles, EntityTypeInterface $bundle_entity_type) {
if (!$bundle_entity_type->isSubclassOf('\Drupal\Core\Entity\EntityDescriptionInterface')) {
if (!$bundle_entity_type->entityClassImplements(EntityDescriptionInterface::class)) {
return $bundles;
}
$bundle_names = array_keys($bundles);
......
......@@ -122,7 +122,7 @@ public function __construct(array $values, $entity_type) {
throw new \InvalidArgumentException('Missing required properties for an EntityDisplay entity.');
}
if (!$this->entityManager()->getDefinition($values['targetEntityType'])->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
if (!$this->entityTypeManager()->getDefinition($values['targetEntityType'])->entityClassImplements(FieldableEntityInterface::class)) {
throw new \InvalidArgumentException('EntityDisplay entities can only handle fieldable entity types.');
}
......
......@@ -195,7 +195,7 @@ protected function buildBaseFieldDefinitions($entity_type_id) {
$keys = array_filter($entity_type->getKeys());
// Fail with an exception for non-fieldable entity types.
if (!$entity_type->isSubclassOf(FieldableEntityInterface::class)) {
if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) {
throw new \LogicException("Getting the base fields is not supported for entity type {$entity_type->getLabel()}.");
}
......@@ -435,7 +435,7 @@ public function getFieldMap() {
// bundles, and we do not expect to have so many different entity
// types for this to become a bottleneck.
foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type->isSubclassOf(FieldableEntityInterface::class)) {
if ($entity_type->entityClassImplements(FieldableEntityInterface::class)) {
$bundles = array_keys($this->entityTypeBundleInfo->getBundleInfo($entity_type_id));
foreach ($this->getBaseFieldDefinitions($entity_type_id) as $field_name => $base_field_definition) {
$this->fieldMap[$entity_type_id][$field_name] = [
......
......@@ -308,7 +308,7 @@ public function __construct($definition) {
// Automatically add the EntityChanged constraint if the entity type tracks
// the changed time.
if ($this->isSubclassOf('Drupal\Core\Entity\EntityChangedInterface') ) {
if ($this->entityClassImplements(EntityChangedInterface::class) ) {
$this->addConstraint('EntityChanged');
}
......@@ -429,11 +429,18 @@ public function setClass($class) {
return $this;
}
/**
* {@inheritdoc}
*/
public function entityClassImplements($interface) {
return is_subclass_of($this->getClass(), $interface);
}
/**
* {@inheritdoc}
*/
public function isSubclassOf($class) {
return is_subclass_of($this->getClass(), $class);
return $this->entityClassImplements($class);
}
/**
......
......@@ -351,6 +351,17 @@ public function getAccessControlClass();
*/
public function setAccessClass($class);
/**
* Indicates if the entity type class implements the given interface.
*
* @param string $interface
* The class or interface to check.
*
* @return bool
* TRUE if the entity type class implements the given interface.
*/
public function entityClassImplements($interface);
/**
* Indicates if the entity type is a subclass of the given class or interface.
*
......@@ -359,6 +370,10 @@ public function setAccessClass($class);
*
* @return bool
* TRUE if the entity type is a subclass of the class or interface.
*
* @deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0.
* Use Drupal\Core\Entity\EntityTypeInterface::entityClassImpelments()
* instead.
*/
public function isSubclassOf($class);
......
......@@ -74,7 +74,7 @@ public function onEntityTypeCreate(EntityTypeInterface $entity_type) {
$this->eventDispatcher->dispatch(EntityTypeEvents::CREATE, new EntityTypeEvent($entity_type));
$this->entityLastInstalledSchemaRepository->setLastInstalledDefinition($entity_type);
if ($entity_type->isSubclassOf(FieldableEntityInterface::class)) {
if ($entity_type->entityClassImplements(FieldableEntityInterface::class)) {
$this->entityLastInstalledSchemaRepository->setLastInstalledFieldStorageDefinitions($entity_type_id, $this->entityFieldManager->getFieldStorageDefinitions($entity_type_id));
}
}
......
......@@ -7,6 +7,7 @@
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
use Drupal\Core\Form\FormStateInterface;
......@@ -157,7 +158,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
);
}
if ($entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
if ($entity_type->entityClassImplements(FieldableEntityInterface::class)) {
$fields = array();
foreach (array_keys($bundles) as $bundle) {
$bundle_fields = array_filter($this->entityManager->getFieldDefinitions($entity_type_id, $bundle), function ($field_definition) {
......
......@@ -341,7 +341,7 @@ protected function getCollectionRoute(EntityTypeInterface $entity_type) {
* type does not support fields.
*/
protected function getEntityTypeIdKeyType(EntityTypeInterface $entity_type) {
if (!$entity_type->isSubclassOf(FieldableEntityInterface::class)) {
if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) {
return NULL;
}
......
......@@ -218,7 +218,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
if ($entity_type->getProvider() == $module) {
$update_manager->installEntityType($entity_type);
}
elseif ($entity_type->isSubclassOf(FieldableEntityInterface::CLASS)) {
elseif ($entity_type->entityClassImplements(FieldableEntityInterface::CLASS)) {
// The module being installed may be adding new fields to existing
// entity types. Field definitions for any entity type defined by
// the module are handled in the if branch.
......@@ -403,7 +403,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
if ($entity_type->getProvider() == $module) {
$update_manager->uninstallEntityType($entity_type);
}
elseif ($entity_type->isSubclassOf(FieldableEntityInterface::CLASS)) {
elseif ($entity_type->entityClassImplements(FieldableEntityInterface::CLASS)) {
// The module being installed may be adding new fields to existing
// entity types. Field definitions for any entity type defined by
// the module are handled in the if branch.
......
......@@ -3,6 +3,7 @@
namespace Drupal\Core\Field;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Entity\FieldableEntityStorageInterface;
use Drupal\Core\Extension\ModuleUninstallValidatorInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
......@@ -43,7 +44,7 @@ public function validate($module_name) {
// We skip entity types defined by the module as there must be no
// content to be able to uninstall them anyway.
// See \Drupal\Core\Entity\ContentUninstallValidator.
if ($entity_type->getProvider() != $module_name && $entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
if ($entity_type->getProvider() != $module_name && $entity_type->entityClassImplements(FieldableEntityInterface::class)) {
foreach ($this->entityManager->getFieldStorageDefinitions($entity_type_id) as $storage_definition) {
if ($storage_definition->getProvider() == $module_name) {
$storage = $this->entityManager->getStorage($entity_type_id);
......
......@@ -6,6 +6,7 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Entity\TypedData\EntityDataDefinition;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemBase;
......@@ -66,7 +67,7 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel
$target_type_info = \Drupal::entityManager()->getDefinition($settings['target_type']);
$target_id_data_type = 'string';
if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
if ($target_type_info->entityClassImplements(FieldableEntityInterface::class)) {
$id_definition = \Drupal::entityManager()->getBaseFieldDefinitions($settings['target_type'])[$target_type_info->getKey('id')];
if ($id_definition->getType() === 'integer') {
$target_id_data_type = 'integer';
......@@ -114,7 +115,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition)
$target_type = $field_definition->getSetting('target_type');
$target_type_info = \Drupal::entityManager()->getDefinition($target_type);
$properties = static::propertyDefinitions($field_definition)['target_id'];
if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface') && $properties->getDataType() === 'integer') {
if ($target_type_info->entityClassImplements(FieldableEntityInterface::class) && $properties->getDataType() === 'integer') {
$columns = array(
'target_id' => array(
'description' => 'The ID of the target entity.',
......
......@@ -2,6 +2,7 @@
namespace Drupal\Core\ParamConverter;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Routing\AdminContext;
use Symfony\Component\Routing\Route;
use Drupal\Core\Config\ConfigFactoryInterface;
......@@ -65,7 +66,7 @@ public function convert($value, $definition, $name, array $defaults) {
// entity types will have performed this check in self::applies().
if (strpos($definition['type'], 'entity:{') === 0) {
$entity_type = $this->entityManager->getDefinition($entity_type_id);
if (!$entity_type->isSubclassOf('\Drupal\Core\Config\Entity\ConfigEntityInterface')) {
if (!$entity_type->entityClassImplements(ConfigEntityInterface::class)) {
return parent::convert($value, $definition, $name, $defaults);
}
}
......@@ -93,7 +94,7 @@ public function applies($definition, $name, Route $route) {
// As we only want to override EntityConverter for ConfigEntities, find
// out whether the current entity is a ConfigEntity.
$entity_type = $this->entityManager->getDefinition($entity_type_id);
if ($entity_type->isSubclassOf('\Drupal\Core\Config\Entity\ConfigEntityInterface')) {
if ($entity_type->entityClassImplements(ConfigEntityInterface::class)) {
return $this->adminContext->isAdminRoute($route);
}
}
......
......@@ -341,7 +341,7 @@ function comment_form_field_storage_config_edit_form_alter(&$form, FormStateInte
*/
function comment_entity_storage_load($entities, $entity_type) {
// Comments can only be attached to content entities, so skip others.
if (!\Drupal::entityManager()->getDefinition($entity_type)->isSubclassOf('Drupal\Core\Entity\FieldableEntityInterface')) {
if (!\Drupal::entityManager()->getDefinition($entity_type)->entityClassImplements(FieldableEntityInterface::class)) {
return;
}
// @todo Investigate in https://www.drupal.org/node/2527866 why we need that.
......
......@@ -24,7 +24,7 @@ function comment_token_info() {
$tokens = [];
// Provide a integration for each entity type except comment.
foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type_id == 'comment' || !$entity_type->isSubclassOf(ContentEntityInterface::class)) {
if ($entity_type_id == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class)) {
continue;
}
......
......@@ -5,6 +5,8 @@
* Provide views data for comment.module.
*/
use Drupal\Core\Entity\ContentEntityInterface;
/**
* Implements hook_views_data_alter().
*/
......@@ -22,7 +24,7 @@ function comment_views_data_alter(&$data) {
// Provide a integration for each entity type except comment.
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type_id == 'comment' || !$entity_type->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface') || !$entity_type->getBaseTable()) {
if ($entity_type_id == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) {
continue;
}
$fields = \Drupal::service('comment.manager')->getFields($entity_type_id);
......
......@@ -6,6 +6,7 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Routing\UrlGeneratorInterface;
......@@ -99,7 +100,7 @@ public function __construct(EntityManagerInterface $entity_manager, QueryFactory
*/
public function getFields($entity_type_id) {
$entity_type = $this->entityManager->getDefinition($entity_type_id);
if (!$entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) {
return array();
}
......
......@@ -2,6 +2,7 @@
namespace Drupal\comment;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\views\EntityViewsData;
/**
......@@ -184,7 +185,7 @@ public function getViewsData() {
// Provide a relationship for each entity type except comment.
foreach ($entities_types as $type => $entity_type) {
if ($type == 'comment' || !$entity_type->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface') || !$entity_type->getBaseTable()) {
if ($type == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) {
continue;
}
if ($fields = \Drupal::service('comment.manager')->getFields($type)) {
......@@ -226,7 +227,7 @@ public function getViewsData() {
// Provide a relationship for each entity type except comment.
foreach ($entities_types as $type => $entity_type) {
if ($type == 'comment' || !$entity_type->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface') || !$entity_type->getBaseTable()) {
if ($type == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) {
continue;
}
// This relationship does not use the 'field id' column, if the entity has
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\comment\Unit;
use Drupal\comment\CommentManager;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Tests\UnitTestCase;
/**
......@@ -23,8 +24,8 @@ public function testGetFields() {
->method('getClass')
->will($this->returnValue('Node'));
$entity_type->expects($this->any())
->method('isSubclassOf')
->with('\Drupal\Core\Entity\FieldableEntityInterface')
->method('entityClassImplements')
->with(FieldableEntityInterface::class)
->will($this->returnValue(TRUE));
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
......
......@@ -2,6 +2,7 @@
namespace Drupal\config\Form;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeInterface;
......@@ -73,7 +74,7 @@ public function getFormId() {
*/
public function buildForm(array $form, FormStateInterface $form_state, $config_type = NULL, $config_name = NULL) {
foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
if ($definition->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {
if ($definition->entityClassImplements(ConfigEntityInterface::class)) {
$this->definitions[$entity_type] = $definition;
}
}
......
......@@ -7,6 +7,7 @@
use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Config\ConfigImporterException;
use Drupal\Core\Config\ConfigManagerInterface;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\StorageComparer;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
......@@ -221,7 +222,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$entity_types = array();
foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
if ($definition->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {
if ($definition->entityClassImplements(ConfigEntityInterface::class)) {
$entity_types[$entity_type] = $definition->getLabel();
}
}
......
......@@ -5,6 +5,7 @@
* Configuration Translation module.
*/
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\field\FieldConfigInterface;
......@@ -75,7 +76,7 @@ function config_translation_themes_uninstalled() {
function config_translation_entity_type_alter(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {
if ($entity_type->entityClassImplements(ConfigEntityInterface::class)) {
if ($entity_type_id == 'block') {
$class = 'Drupal\config_translation\Controller\ConfigTranslationBlockListBuilder';
}
......@@ -125,7 +126,7 @@ function config_translation_config_translation_info(&$info) {
// Determine base path for entities automatically if provided via the
// configuration entity.
if (
!$entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface') ||
!$entity_type->entityClassImplements(ConfigEntityInterface::class) ||
!$entity_type->hasLinkTemplate('edit-form')
) {
// Do not record this entity mapper if the entity type does not
......@@ -154,7 +155,7 @@ function config_translation_config_translation_info(&$info) {
function config_translation_entity_operation(EntityInterface $entity) {
$operations = array();
$entity_type = $entity->getEntityType();
if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface') &&
if ($entity_type->entityClassImplements(ConfigEntityInterface::class) &&
$entity->hasLinkTemplate('config-translation-overview') &&
\Drupal::currentUser()->hasPermission('translate configuration')) {
......
......@@ -111,7 +111,7 @@ protected function getLatestVersionRoute(EntityTypeInterface $entity_type) {
* type does not support fields.
*/
protected function getEntityTypeIdKeyType(EntityTypeInterface $entity_type) {
if (!$entity_type->isSubclassOf(FieldableEntityInterface::class)) {
if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) {
return NULL;
}
......
......@@ -4,6 +4,7 @@
use Drupal\Core\Access\AccessResult;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityHandlerInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
......@@ -15,6 +16,7 @@
use Drupal\Core\Render\Element;
use Drupal\Core\Session\AccountInterface;
use Drupal\user\Entity\User;
use Drupal\user\EntityOwnerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -174,7 +176,7 @@ protected function hasAuthor() {
// EntityOwnerInterface. This helps to exclude cases, where the uid is
// defined as field name, but is not meant to be an owner field; for
// instance, the User entity.
return $this->entityType->isSubclassOf('\Drupal\user\EntityOwnerInterface') && $this->checkFieldStorageDefinitionTranslatability('uid');
return $this->entityType->entityClassImplements(EntityOwnerInterface::class) && $this->checkFieldStorageDefinitionTranslatability('uid');
}
/**
......@@ -194,7 +196,7 @@ protected function hasPublishedStatus() {
* TRUE if metadata is natively supported, FALSE otherwise.
*/
protected function hasChangedTime() {
return $this->entityType->isSubclassOf('Drupal\Core\Entity\EntityChangedInterface') && $this->checkFieldStorageDefinitionTranslatability('changed');
return $this->entityType->entityClassImplements(EntityChangedInterface::class) && $this->checkFieldStorageDefinitionTranslatability('changed');
}
/**
......
......@@ -3,6 +3,7 @@
namespace Drupal\content_translation\Tests;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageInterface;
......@@ -599,7 +600,7 @@ public function doTestChangedTimeAfterSaveWithoutChanges() {
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
// Test only entities, which implement the EntityChangedInterface.
if ($entity->getEntityType()->isSubclassOf('Drupal\Core\Entity\EntityChangedInterface')) {
if ($entity instanceof EntityChangedInterface) {
$changed_timestamp = $entity->getChangedTime();
$entity->save();
......
......@@ -263,7 +263,7 @@ protected function getContentEntityPaths() {
$this->contentEntityPaths = [];
$entity_types = $this->entityManager->getDefinitions();
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($entity_type->isSubclassOf(ContentEntityInterface::class)) {
if ($entity_type->entityClassImplements(ContentEntityInterface::class)) {
$entity_paths = array_fill_keys($entity_type->getLinkTemplates(), $entity_type_id);
$this->contentEntityPaths = array_merge($this->contentEntityPaths, $entity_paths);
}
......
......@@ -5,6 +5,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
......@@ -127,7 +128,7 @@ protected function writeCache($context = array()) {
foreach ($this->bundleInfoService->getAllBundleInfo() as $entity_type_id => $bundles) {
// Only content entities are supported currently.
// @todo Consider supporting config entities.
if ($entity_types[$entity_type_id]->isSubclassOf('\Drupal\Core\Config\Entity\ConfigEntityInterface')) {
if ($entity_types[$entity_type_id]->entityClassImplements(ConfigEntityInterface::class)) {
continue;
}
foreach ($bundles as $bundle => $bundle_info) {
......
......@@ -543,7 +543,7 @@ protected function setUpEntityWithFieldDefinition($custom_invoke_all = FALSE, $f
$this->entityType->getClass()->willReturn($entity_class);
$this->entityType->getKeys()->willReturn($entity_keys + ['default_langcode' => 'default_langcode']);
$this->entityType->isSubclassOf(FieldableEntityInterface::class)->willReturn(TRUE);
$this->entityType->entityClassImplements(FieldableEntityInterface::class)->willReturn(TRUE);
$this->entityType->isTranslatable()->willReturn(FALSE);
$this->entityType->getProvider()->willReturn('the_provider');
$this->entityType->id()->willReturn('the_entity_id');
......@@ -652,13 +652,13 @@ public function testGetFieldMap() {
$entity_type->getClass()->willReturn($entity_class);
$entity_type->getKeys()->willReturn(['default_langcode' => 'default_langcode']);
$entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(TRUE);
$entity_type->entityClassImplements(FieldableEntityInterface::class)->willReturn(TRUE);
$entity_type->isTranslatable()->shouldBeCalled();
$entity_type->getProvider()->shouldBeCalled();
$non_content_entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(FALSE);
$non_content_entity_type->entityClassImplements(FieldableEntityInterface::class)->willReturn(FALSE);
$override_entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(FALSE);
$override_entity_type->entityClassImplements(FieldableEntityInterface::class)->willReturn(FALSE);
// Set up the entity type bundle info to return two bundles for the
// fieldable entity type.
......@@ -753,11 +753,11 @@ public function testGetFieldMapByFieldType() {
$entity_type->getClass()->willReturn($entity_class)->shouldBeCalled();
$entity_type->getKeys()->willReturn(['default_langcode' => 'default_langcode'])->shouldBeCalled();
$entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(TRUE)->shouldBeCalled();
$entity_type->entityClassImplements(FieldableEntityInterface::class)->willReturn(TRUE)->shouldBeCalled();
$entity_type->isTranslatable()->shouldBeCalled();
$entity_type->getProvider()->shouldBeCalled();
$override_entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(FALSE)->shouldBeCalled();
$override_entity_type->entityClassImplements(FieldableEntityInterface::class)->willReturn(FALSE)->shouldBeCalled();
$integerFields = $this->entityFieldManager->getFieldMapByFieldType('integer');
$this->assertCount(1, $integerFields['test_entity_type']);
......
......@@ -159,7 +159,7 @@ public function providerTestGetAddFormRoute() {
$entity_type5->getBundleEntityType()->willReturn('the_bundle_entity_type_id');
$entity_type5->getLinkTemplate('add-form')->willReturn('/the/add/form/link/template/{the_bundle_entity_type_id}');
$bundle_entity_type = $this->getEntityType();
$bundle_entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(FALSE);
$bundle_entity_type->entityClassImplements(FieldableEntityInterface::class)->willReturn(FALSE);
$route->setPath('/the/add/form/link/template/{the_bundle_entity_type_id}');
$route
->setDefault('bundle_parameter', 'the_bundle_entity_type_id')
......@@ -171,7 +171,7 @@ public function providerTestGetAddFormRoute() {
$entity_type6 = $this->getEntityType($entity_type5);
$bundle_entity_type = $this->getEntityType();
$bundle_entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(TRUE);
$bundle_entity_type->entityClassImplements(FieldableEntityInterface::class)->willReturn(TRUE);
$field_storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class);
$field_storage_definition->getType()->willReturn('integer');
$route->setRequirement('the_entity_type_id', '\d+');
......@@ -179,7 +179,7 @@ public function providerTestGetAddFormRoute() {
$entity_type7 = $this->getEntityType($entity_type6);
$bundle_entity_type = $this->prophesize(ConfigEntityTypeInterface::class);
$bundle_entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(FALSE);
$bundle_entity_type->entityClassImplements(FieldableEntityInterface::class)->willReturn(FALSE);
$field_storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class);
$route
// Unset the 'the_entity_type_id' requirement.
......@@ -223,7 +223,7 @@ public function providerTestGetCanonicalRoute() {
$entity_type3->hasViewBuilderClass()->willReturn(TRUE);
$entity_type3->id()->willReturn('the_entity_type_id');
$entity_type3->getLinkTemplate('canonical')->willReturn('/the/canonical/link/template');
$entity_type3->isSubclassOf(FieldableEntityInterface::class)->willReturn(FALSE);
$entity_type3->entityClassImplements(FieldableEntityInterface::class)->willReturn(FALSE);
$route = (new Route('/the/canonical/link/template'))
->setDefaults([
'_entity_view' => 'the_entity_type_id.full',
......@@ -242,7 +242,7 @@ public function providerTestGetCanonicalRoute() {
$data['id_key_type_null'] = [clone $route, $entity_type3->reveal()];
$entity_type4 = $this->getEntityType($entity_type3);
$entity_type4->isSubclassOf(FieldableEntityInterface::class)->willReturn(TRUE);
$entity_type4->entityClassImplements(FieldableEntityInterface::class)->willReturn(TRUE);
$entity_type4->getKey('id')->willReturn('id');
$route->setRequirement('the_entity_type_id', '\d+');
$field_storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class);
......@@ -283,7 +283,7 @@ public function providerTestGetCollectionRoute() {
$entity_type4->id()->willReturn('the_entity_type_id');
$entity_type4->getLabel()->willReturn('The entity type');
$entity_type4->getLinkTemplate('collection')->willReturn('/the/collection/link/template');
$entity_type4->isSubclassOf(FieldableEntityInterface::class)->willReturn(FALSE);
$entity_type4->entityClassImplements(FieldableEntityInterface::class)->willReturn(FALSE);
$route = (new Route('/the/collection/link/template'))
->setDefaults([
'_entity_list' => 'the_entity_type_id',
......@@ -303,7 +303,7 @@ public function providerTestGetCollectionRoute() {
*/
public function testGetEntityTypeIdKeyType() {
$entity_type = $this->prophesize(EntityTypeInterface::class);
$entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(TRUE);
$entity_type->entityClassImplements(FieldableEntityInterface::class)->willReturn(TRUE);
$entity_type->id()->willReturn('the_entity_type_id');
$entity_type->getKey('id')->willReturn('id');
......@@ -320,7 +320,7 @@ public function testGetEntityTypeIdKeyType() {
*/
public function testGetEntityTypeIdKeyTypeNotFieldable() {
$entity_type = $this->prophesize(EntityTypeInterface::class);
$entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(FALSE);
$entity_type->entityClassImplements(FieldableEntityInterface::class)->willReturn(FALSE);
$this->entityFieldManager->getFieldStorageDefinitions(Argument::any())->shouldNotBeCalled();