diff --git a/file_entity.module b/file_entity.module index 49f0789..4a82468 100644 --- a/file_entity.module +++ b/file_entity.module @@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Routing\RouteMatchInterface; @@ -393,7 +394,11 @@ function file_entity_entity_storage_load($entities, $entity_type) { // Loop over all the entities looking for entities with attached images. foreach ($entities as $entity) { - /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ + // Skip non-fieldable entities. + if (!$entity instanceof FieldableEntityInterface) { + continue; + } + /** @var \Drupal\Core\Entity\FieldableEntityInterface $entity */ // Examine every image field instance attached to this entity's bundle. foreach ($entity->getFieldDefinitions() as $field_definition) { if ($field_definition->getSetting('target_type') == 'file' && $field_definition->getType() != 'image') { diff --git a/src/Entity/FileEntity.php b/src/Entity/FileEntity.php index e1c5787..586c729 100644 --- a/src/Entity/FileEntity.php +++ b/src/Entity/FileEntity.php @@ -3,9 +3,9 @@ namespace Drupal\file_entity\Entity; use Drupal\Core\Cache\Cache; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Site\Settings; use Drupal\Core\StreamWrapper\StreamWrapperInterface; @@ -270,12 +270,12 @@ class FileEntity extends File implements FileEntityInterface { /** * Update the image dimensions on the given image field on the given entity. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity to be updated. * @param string $image_field * The field to be updated. */ - protected function updateImageFieldDimensionsByEntity(ContentEntityInterface $entity, $image_field) { + protected function updateImageFieldDimensionsByEntity(FieldableEntityInterface $entity, $image_field) { foreach (array_keys($entity->getTranslationLanguages()) as $langcode) { $translation = $entity->getTranslation($langcode);