public static function MigrateDestinationEntity::fieldAttachValidate in Migrate 7.2
Perform field validation against the field data in an entity. Wraps field_attach_validate to handle exceptions cleanly and provide maximum information for identifying the cause of validation errors.
Parameters
$entity_type: The type of $entity; e.g. 'node' or 'user'.
$entity: The entity with fields to validate.
5 calls to MigrateDestinationEntity::fieldAttachValidate()
- MigrateDestinationComment::import in plugins/
destinations/ comment.inc - Import a single comment.
- MigrateDestinationNode::import in plugins/
destinations/ node.inc - Import a single node.
- MigrateDestinationTerm::import in plugins/
destinations/ term.inc - Import a single term.
- MigrateDestinationUser::import in plugins/
destinations/ user.inc - Import a single user.
- MigrateTaxonomyTermReferenceFieldHandler::prepare in plugins/
destinations/ fields.inc
File
- plugins/
destinations/ entity.inc, line 194 - Defines base for migration destinations implemented as Drupal entities.
Class
- MigrateDestinationEntity
- Abstract base class for entity-based destination handling. Holds common Field API-related functions.
Code
public static function fieldAttachValidate($entity_type, $entity) {
try {
field_attach_validate($entity_type, $entity);
} catch (FieldValidationException $e) {
$migration = Migration::currentMigration();
foreach ($e->errors as $field_name => $error_list) {
if (is_array($error_list)) {
foreach ($error_list as $index => $error) {
// Flatten the array to make sure the "message" field is at the top
// level.
$error = self::array_flatten($error);
$message = $error['message'];
$migration
->saveMessage(t('Field validation error for !field_name: !message', array(
'!field_name' => $field_name,
'!message' => $message,
)));
}
}
}
}
}