diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index ca17e64..8c44a1e 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -128,7 +128,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->entityManager()->getDefinition($values['targetEntityType']) instanceof ContentEntityTypeInterface) { throw new \InvalidArgumentException('EntityDisplay entities can only handle fieldable entity types.'); } diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index fcba978..60a3ef7 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -406,7 +406,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('\Drupal\Core\Entity\FieldableEntityInterface')) { + if (!($entity_type instanceof ContentEntityTypeInterface)) { throw new \LogicException(SafeMarkup::format('Getting the base fields is not supported for entity type @type.', array('@type' => $entity_type->getLabel()))); } @@ -644,7 +644,7 @@ public function getFieldMap() { else { // Rebuild the definitions and put it into the cache. foreach ($this->getDefinitions() as $entity_type_id => $entity_type) { - if ($entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { + if ($entity_type instanceof ContentEntityTypeInterface) { foreach ($this->getBundleInfo($entity_type_id) as $bundle => $bundle_info) { foreach ($this->getFieldDefinitions($entity_type_id, $bundle) as $field_name => $field_definition) { $this->fieldMap[$entity_type_id][$field_name]['type'] = $field_definition->getType(); @@ -1087,7 +1087,7 @@ public function onEntityTypeCreate(EntityTypeInterface $entity_type) { $this->eventDispatcher->dispatch(EntityTypeEvents::CREATE, new EntityTypeEvent($entity_type)); $this->setLastInstalledDefinition($entity_type); - if ($entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { + if ($entity_type instanceof ContentEntityTypeInterface) { $this->setLastInstalledFieldStorageDefinitions($entity_type_id, $this->getFieldStorageDefinitions($entity_type_id)); } } diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index e121d75..560a624 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -270,7 +270,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 (is_subclass_of($this->getClass(), 'Drupal\Core\Entity\EntityChangedInterface')) { $this->addConstraint('EntityChanged'); } diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php index cb8c7d6..98146ab 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Database\Query\AlterableInterface; use Drupal\Core\Database\Query\SelectInterface; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; @@ -142,7 +143,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta ); } - if ($entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { + if ($entity_type instanceof ContentEntityTypeInterface) { $fields = array(); foreach (array_keys($bundles) as $bundle) { $bundle_fields = array_filter($this->entityManager->getFieldDefinitions($entity_type_id, $bundle), function ($field_definition) { diff --git a/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php b/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php index b54579c..74e449c 100644 --- a/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php +++ b/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\FieldableEntityStorageInterface; use Drupal\Core\Extension\ModuleUninstallValidatorInterface; @@ -48,7 +49,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 instanceof ContentEntityTypeInterface) { foreach ($this->entityManager->getFieldStorageDefinitions($entity_type_id) as $storage_definition) { if ($storage_definition->getProvider() == $module_name) { $storage = $this->entityManager->getStorage($entity_type_id); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index ca54aa8..cc90a3f 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\TypedData\EntityDataDefinition; @@ -72,7 +73,7 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel $settings = $field_definition->getSettings(); $target_type_info = \Drupal::entityManager()->getDefinition($settings['target_type']); - if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { + if ($target_type_info instanceof ContentEntityTypeInterface) { // @todo: Lookup the entity type's ID data type and use it here. // https://drupal.org/node/2107249 $target_id_definition = DataDefinition::create('integer') @@ -120,7 +121,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) $target_type = $field_definition->getSetting('target_type'); $target_type_info = \Drupal::entityManager()->getDefinition($target_type); - if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { + if ($target_type_info instanceof ContentEntityTypeInterface) { $columns = array( 'target_id' => array( 'description' => 'The ID of the target entity.', diff --git a/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php b/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php index ec09f68..fbdaa3c 100644 --- a/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php +++ b/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php @@ -7,6 +7,7 @@ namespace Drupal\Core\ParamConverter; +use Drupal\Core\Config\Entity\ConfigEntityTypeInterface; use Drupal\Core\Routing\AdminContext; use Symfony\Component\Routing\Route; use Drupal\Core\Config\ConfigFactoryInterface; @@ -71,7 +72,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 instanceof ConfigEntityTypeInterface) { return parent::convert($value, $definition, $name, $defaults); } } @@ -99,7 +100,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 instanceof ConfigEntityTypeInterface) { return $this->adminContext->isAdminRoute($route); } } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index debc2d3..f06d608 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -14,6 +14,7 @@ use Drupal\comment\Entity\Comment; use Drupal\comment\CommentManagerInterface; use Drupal\comment\Entity\CommentType; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Component\Utility\SafeMarkup; @@ -311,7 +312,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) instanceof ContentEntityTypeInterface) { return; } if (!\Drupal::service('comment.manager')->getFields($entity_type)) { diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index 5e31876..69a1cec 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -4,6 +4,7 @@ * @file * Provide views data for comment.module. */ +use Drupal\Core\Entity\ContentEntityTypeInterface; /** * Implements hook_views_data_alter(). @@ -22,7 +23,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 instanceof ContentEntityTypeInterface || !$entity_type->getBaseTable()) { continue; } $fields = \Drupal::service('comment.manager')->getFields($entity_type_id); diff --git a/core/modules/comment/src/CommentManager.php b/core/modules/comment/src/CommentManager.php index 45705a2..46d2572 100644 --- a/core/modules/comment/src/CommentManager.php +++ b/core/modules/comment/src/CommentManager.php @@ -10,6 +10,7 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; @@ -105,7 +106,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 instanceof ContentEntityTypeInterface) { return array(); } diff --git a/core/modules/comment/src/CommentViewsData.php b/core/modules/comment/src/CommentViewsData.php index e853a58..4b0bdd6 100644 --- a/core/modules/comment/src/CommentViewsData.php +++ b/core/modules/comment/src/CommentViewsData.php @@ -7,6 +7,7 @@ namespace Drupal\comment; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\views\EntityViewsData; /** @@ -159,7 +160,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 instanceof ContentEntityTypeInterface || !$entity_type->getBaseTable()) { continue; } if ($fields = \Drupal::service('comment.manager')->getFields($type)) { @@ -211,7 +212,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 instanceof ContentEntityTypeInterface || !$entity_type->getBaseTable()) { continue; } // This relationship does not use the 'field id' column, if the entity has diff --git a/core/modules/config/src/Form/ConfigSingleExportForm.php b/core/modules/config/src/Form/ConfigSingleExportForm.php index c95f0d8..0c2522f 100644 --- a/core/modules/config/src/Form/ConfigSingleExportForm.php +++ b/core/modules/config/src/Form/ConfigSingleExportForm.php @@ -8,6 +8,7 @@ namespace Drupal\config\Form; use Drupal\Component\Serialization\Yaml; +use Drupal\Core\Config\Entity\ConfigEntityTypeInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; @@ -77,7 +78,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 instanceof ConfigEntityTypeInterface) { $this->definitions[$entity_type] = $definition; } } diff --git a/core/modules/config/src/Form/ConfigSingleImportForm.php b/core/modules/config/src/Form/ConfigSingleImportForm.php index 84c19db..b12da1d 100644 --- a/core/modules/config/src/Form/ConfigSingleImportForm.php +++ b/core/modules/config/src/Form/ConfigSingleImportForm.php @@ -8,6 +8,7 @@ namespace Drupal\config\Form; use Drupal\Component\Serialization\Yaml; +use Drupal\Core\Config\Entity\ConfigEntityTypeInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\ConfirmFormBase; @@ -123,7 +124,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 instanceof ConfigEntityTypeInterface) { $entity_types[$entity_type] = $definition->getLabel(); } } diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index ea4e532..2762015 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -6,6 +6,7 @@ */ use Drupal\config_translation\Plugin\Derivative\ConfigTranslationLocalTasks; +use Drupal\Core\Config\Entity\ConfigEntityTypeInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\field\FieldConfigInterface; @@ -77,7 +78,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 instanceof ConfigEntityTypeInterface) { if ($entity_type_id == 'block') { $class = 'Drupal\config_translation\Controller\ConfigTranslationBlockListBuilder'; } @@ -129,7 +130,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 instanceof ConfigEntityTypeInterface || !$entity_type->hasLinkTemplate('edit-form') ) { // Do not record this entity mapper if the entity type does not @@ -158,7 +159,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 instanceof ConfigEntityTypeInterface && $entity->hasLinkTemplate('config-translation-overview') && \Drupal::currentUser()->hasPermission('translate configuration')) { diff --git a/core/modules/rest/src/LinkManager/TypeLinkManager.php b/core/modules/rest/src/LinkManager/TypeLinkManager.php index 4160b2b..4f1cb23 100644 --- a/core/modules/rest/src/LinkManager/TypeLinkManager.php +++ b/core/modules/rest/src/LinkManager/TypeLinkManager.php @@ -9,6 +9,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Utility\UnroutedUrlAssemblerInterface; class TypeLinkManager implements TypeLinkManagerInterface { @@ -96,7 +97,7 @@ protected function writeCache() { foreach (entity_get_bundles() 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] instanceof ContentEntityTypeInterface)) { continue; } foreach ($bundles as $bundle => $bundle_info) {