You are here

public static function ResourceField::fieldClassName in RESTful 7.2

Get the class name to use based on the field definition.

Parameters

array $field_definition: The processed field definition with the user values.

Return value

string The class name to use. If the class name is empty or does not implement ResourceFieldInterface then ResourceField will be used. NULL if nothing was found.

1 call to ResourceField::fieldClassName()
ResourceField::create in src/Plugin/resource/Field/ResourceField.php
Factory.

File

src/Plugin/resource/Field/ResourceField.php, line 143
Contains \Drupal\restful\Plugin\resource\ResourceField.

Class

ResourceField

Namespace

Drupal\restful\Plugin\resource\Field

Code

public static function fieldClassName(array $field_definition) {
  if (!empty($field_definition['class'])) {
    $class_name = $field_definition['class'];
  }
  elseif (!empty($field_definition['sub_property']) || !empty($field_definition['formatter']) || !empty($field_definition['wrapper_method']) || !empty($field_definition['wrapper_method_on_entity']) || !empty($field_definition['column']) || !empty($field_definition['image_styles']) || (!empty($field_definition['property']) ? field_info_field($field_definition['property']) : NULL)) {
    $class_name = '\\Drupal\\restful\\Plugin\\resource\\Field\\ResourceFieldEntity';
  }
  elseif (!empty($field_definition['property'])) {
    $class_name = '\\Drupal\\restful\\Plugin\\resource\\Field\\ResourceFieldKeyValue';
  }
  if (!empty($class_name) && class_exists($class_name) && in_array('Drupal\\restful\\Plugin\\resource\\Field\\ResourceFieldInterface', class_implements($class_name))) {
    return $class_name;
  }
  return NULL;
}