- throw new FieldException(format_string('Attempt to create an instance of field @field_name that does not exist on entity type @entity_type.', array('@field_name' => $values['field_name'], '@entity_type' => $values['entity_type'])));

- }

+ // Check required properties.

+ if (empty($values['field_name'])) {

+ throw new FieldException('Attempt to create an instance of a field without a field_name.');

- throw new FieldException(format_string('Attempt to create an instance of field @field_name that does not exist on entity type @entity_type.', array('@field_name' => $values['field_name'], '@entity_type' => $values['entity_type'])));

- }

- $values['field_uuid'] = $field->uuid();

+ if (empty($values['entity_type'])) {

+ throw new FieldException(String::format('Attempt to create an instance of field @field_name without an entity_type.', array('@field_name' => $values['field_name'])));

}

- else {

- throw new FieldException('Attempt to create an instance of an unspecified field.');

+ if (empty($values['bundle'])) {

+ throw new FieldException(String::format('Attempt to create an instance of field @field_name without a bundle.', array('@field_name' => $values['field_name'])));

}

- // At this point, we have a Field we can assign.

- $this->field = $field;

-

// Discard the 'field_type' entry that is added in config records to ease

// schema generation. See self::toArray().

unset($values['field_type']);

- // Check required properties.

- if (empty($values['entity_type'])) {

- throw new FieldException(format_string('Attempt to create an instance of field @field_name without an entity_type.', array('@field_name' => $this->field->name)));

- }

- if (empty($values['bundle'])) {

- throw new FieldException(format_string('Attempt to create an instance of field @field_name without a bundle.', array('@field_name' => $this->field->name)));

- }

-

- // 'Label' defaults to the field name (mostly useful for field instances

+ throw new FieldException(String::format('Attempt to create an instance of field @field_name that does not exist on entity type @entity_type.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type)));

+ throw new FieldException(String::format('Attempt to create an instance of field @field_name that does not exist on entity type @entity_type.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type)));