You are here

public function EntityReferenceFieldDependencyCollector::fieldCondition in Dependency Calculation 8

Determines if the field is of one of the specified types.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

string $field_name: The field name.

\Drupal\Core\Field\FieldItemListInterface $field: The field.

Return value

bool Whether the field type is one of the specified ones.

File

src/EventSubscriber/DependencyCollector/EntityReferenceFieldDependencyCollector.php, line 69

Class

EntityReferenceFieldDependencyCollector
Subscribes to dependency collection to extract referenced entities.

Namespace

Drupal\depcalc\EventSubscriber\DependencyCollector

Code

public function fieldCondition(ContentEntityInterface $entity, $field_name, FieldItemListInterface $field) {
  return in_array($field
    ->getFieldDefinition()
    ->getType(), [
    'file',
    'image',
    'entity_reference',
    'entity_reference_revisions',
  ]);
}