You are here

protected function EntityFieldOperationCompareType::getEntityFieldValue in Entity Field Condition 2.0.x

Get entity field value.

Parameters

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

string $field_name: The entity field name.

Return value

mixed|string The entity field value.

1 call to EntityFieldOperationCompareType::getEntityFieldValue()
EntityFieldOperationCompareType::evaluate in src/Plugin/EntityFieldCondition/CompareType/EntityFieldOperationCompareType.php
Evaluate the entity field value.

File

src/Plugin/EntityFieldCondition/CompareType/EntityFieldOperationCompareType.php, line 145

Class

EntityFieldOperationCompareType
Define the entity field operation compare type plugin.

Namespace

Drupal\entity_field_condition\Plugin\EntityFieldCondition\CompareType

Code

protected function getEntityFieldValue(ContentEntityInterface $entity, string $field_name) {
  $field = $entity
    ->get($field_name);
  $value = $field->value;
  if ($this
    ->getValueType() === 'string') {
    $value = $field
      ->getString();
  }
  return $value;
}