src/Service/NT8PropertyService.php
public static function getNodeFieldValue(
    EntityInterface $node,
    string $fieldName,
    int $index = -1,
    string $keyname = 'value'
  ) {
    $field_instance = static::getNodeField($node, $fieldName);
    $field_instance_value = $field_instance->getValue();

    if ($index > -1) {
      $field_instance_value = $field_instance_value[$index][$keyname];
    }

    return $field_instance_value;
  }
public static function getNodeFieldValue(
    EntityInterface $node,
    string $fieldName,
    int $index = -1,
    string $keyname = 'value'
  ) {
    $field_instance = static::getNodeField($node, $fieldName);
    $field_instance_value = $field_instance->getValue();

    if ($index > -1) {
      $field_instance_value = $field_instance_value[$index][$keyname];
    }

    return $field_instance_value;
  }
public static function getNodeFieldValue ( EntityInterface $ node , string $ fieldName , int $ index = - 1 , string $ keyname = 'value' ) { $ field_instance = static :: getNodeField ( $ node , $ fieldName ) ; $ field_instance_value = $ field_instance -> getValue ( ) ; if ( $ index > - 1 ) { $ field_instance_value = $ field_instance_value [ $ index ] [ $ keyname ] ; } return $ field_instance_value ; }
Retrieves a field value from a specified node.

@param \Drupal\Core\Entity\EntityInterface $node
Loaded property node.
@param string $fieldName
Field to load.
@param int $index
Load $index of the field instance array.
@param string $keyname
Load $keyname of the specified $index of the field instance array.

@return mixed
The field value as specified by the parameters.
Retrieves a field value from a specified node .