class MigrateFieldsNodeHandler in Migrate 6.2
@file Support for processing CCK fields
Hierarchy
- class \MigrateHandler
- class \MigrateDestinationHandler
- class \MigrateFieldsNodeHandler
- class \MigrateDestinationHandler
Expanded class hierarchy of MigrateFieldsNodeHandler
1 string reference to 'MigrateFieldsNodeHandler'
File
- plugins/
destinations/ fields.inc, line 8 - Support for processing CCK fields
View source
class MigrateFieldsNodeHandler extends MigrateDestinationHandler {
public function __construct() {
$this
->registerTypes(array(
'node',
));
}
public function fields($entity_type, $bundle) {
$fields = array();
if (module_exists('content')) {
$content_info = _content_type_info();
foreach ($content_info['content types'][$bundle]['fields'] as $machine_name => $instance) {
$fields[$machine_name] = t('Node:') . ' ' . $instance['widget']['label'] . ' (' . $instance['type'] . ')';
// Look for subfields
$class_list = _migrate_class_list('MigrateFieldHandler');
$disabled = unserialize(variable_get('migrate_disabled_handlers', serialize(array())));
foreach ($class_list as $class_name => $handler) {
if (!in_array($class_name, $disabled) && $handler
->handlesType($instance['type']) && method_exists($handler, 'fields')) {
migrate_instrument_start($class_name . '->fields');
$subfields = call_user_func(array(
$handler,
'fields',
), $instance['type']);
migrate_instrument_stop($class_name . '->fields');
foreach ($subfields as $subfield_name => $subfield_label) {
$fields[$machine_name . ':' . $subfield_name] = $subfield_label;
}
}
}
}
}
return $fields;
}
public function prepare($entity, stdClass $row) {
migrate_instrument_start('MigrateDestinationEntity->prepareFields');
// Look for Field API fields attached to this destination and handle appropriately
$migration = Migration::currentMigration();
$destination = $migration
->getDestination();
$bundle = $destination
->getBundle();
$info = content_types($bundle);
$instances = $info['fields'];
foreach ($instances as $machine_name => $instance) {
if (property_exists($entity, $machine_name)) {
// Normalize to an array
if (!is_array($entity->{$machine_name})) {
$entity->{$machine_name} = array(
$entity->{$machine_name},
);
}
$entity->{$machine_name} = migrate_field_handler_invoke_all($entity, $instance, $entity->{$machine_name});
}
}
migrate_instrument_stop('MigrateDestinationEntity->prepareFields');
}
public function complete($entity, stdClass $row) {
migrate_instrument_start('MigrateDestinationEntity->completeFields');
// Look for Field API fields attached to this destination and handle appropriately
$migration = Migration::currentMigration();
$destination = $migration
->getDestination();
$entity_type = $destination
->getEntityType();
$bundle = $destination
->getBundle();
$info = content_types($bundle);
$instances = $info['fields'];
foreach ($instances as $machine_name => $instance) {
if (property_exists($entity, $machine_name)) {
// Normalize to an array
if (!is_array($entity->{$machine_name})) {
$entity->{$machine_name} = array(
$entity->{$machine_name},
);
}
migrate_field_handler_invoke_all($entity, $instance, $entity->{$machine_name}, 'complete');
}
}
migrate_instrument_stop('MigrateDestinationEntity->completeFields');
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateFieldsNodeHandler:: |
public | function | ||
MigrateFieldsNodeHandler:: |
public | function | ||
MigrateFieldsNodeHandler:: |
public | function | ||
MigrateFieldsNodeHandler:: |
public | function |
Overrides MigrateHandler:: |
|
MigrateHandler:: |
protected | property | List of other handler classes which should be invoked before the current one. | |
MigrateHandler:: |
protected | property | List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc. | |
MigrateHandler:: |
public | function | ||
MigrateHandler:: |
public | function | ||
MigrateHandler:: |
public | function | Does this handler handle the given type? | |
MigrateHandler:: |
protected | function | Register a list of types handled by this class |