You are here

public function FieldInstance::__construct in Corresponding Entity References 7.3

1 call to FieldInstance::__construct()
CerField::__construct in includes/CerField.inc
Constructor. Pretty self-explanatory!
1 method overrides FieldInstance::__construct()
CerField::__construct in includes/CerField.inc
Constructor. Pretty self-explanatory!

File

field_object/includes/FieldInstance.inc, line 66

Class

FieldInstance

Code

public function __construct($entity_type, $bundle, $field_name) {
  $this->entityType = $entity_type;
  $this->bundle = $bundle;
  $this->name = $field_name;

  // Get info about the entity type and bundle hosting this field instance.
  $info = entity_get_info($entity_type);
  $this->isBundleable = (bool) $info['entity keys']['bundle'];
  $this->entityTypeLabel = $info['label'];
  $this->bundleLabel = $info['bundles'][$bundle]['label'];

  // Get global info about the field.
  $info = field_info_field($field_name);
  $this->cardinality = $info['cardinality'];

  // Finally, get info about the field instance.
  $instance = field_info_instance($entity_type, $field_name, $bundle);
  $this->label = $instance['label'];
}