class MigrateDestinationRestrictions in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3
Destination class implementing migration into nodes.
Hierarchy
- class \MigrateDestination
- class \MigrateDestinationEntity
Expanded class hierarchy of MigrateDestinationRestrictions
File
- merci_migrate/
merci_restrictions.inc, line 97 - Support for node destinations.
View source
class MigrateDestinationRestrictions extends MigrateDestinationEntity {
protected $bypassDestIdCheck = FALSE;
public static function getKeySchema() {
return array(
'id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique ID.',
),
);
}
public function __construct($bundle, array $options = array()) {
parent::__construct('merci_restrictions', $bundle, $options);
}
/**
* Returns a list of fields available to be mapped for the node type (bundle)
*
* @param Migration $migration
* Optionally, the migration containing this destination.
* @return array
* Keys: machine names of the fields (to be passed to addFieldMapping)
* Values: Human-friendly descriptions of the fields.
*/
public function fields($migration = NULL) {
$fields = array();
// First the core (node table) properties
$fields['id'] = t('Entity ID');
$fields['type'] = t('Type');
$fields['title'] = t('Title');
// Then add in anything provided by handlers
$fields += migrate_handler_invoke_all('Entity', 'fields', $this->entityType, $this->bundle, $migration);
return $fields;
}
/**
* Import a single node.
*
* @param $node
* Node object to build. Prefilled with any fields mapped in the Migration.
* @param $row
* Raw source data object - passed through to prepare/complete handlers.
* @return array
* Array of key fields (nid only in this case) of the node that was saved if
* successful. FALSE on failure.
*/
public function import(stdClass $object, stdClass $row) {
// Updating previously-migrated content?
$migration = Migration::currentMigration();
if (!isset($object->type)) {
// Default the type to our designated destination bundle (by doing this
// conditionally, we permit some flexibility in terms of implementing
// migrations which can affect more than one type).
$object->type = $this->bundle;
}
// Invoke migration prepare handlers
$this
->prepare($object, $row);
// Validate field data prior to saving.
MigrateDestinationEntity::fieldAttachValidate('merci_restrictions', $object);
migrate_instrument_start('merci_restrictions__save');
entity_save('merci_restrictions', $object);
migrate_instrument_stop('merci_restrictions_save');
if (isset($object->id)) {
$this->numCreated++;
$return = array(
$object->id,
);
}
else {
$return = FALSE;
}
$this
->complete($object, $row);
return $return;
}
public function rollback(array $id) {
static $count = 0;
migrate_instrument_start('merci_restrictions_delete');
$this
->prepareRollback($id);
entity_delete('merci_restrictions', reset($id));
$this
->completeRollback($id);
migrate_instrument_stop('merci_restrictions_delete');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateDestination:: |
protected | property | Maintain stats on the number of destination objects created or updated. | |
MigrateDestination:: |
protected | property | ||
MigrateDestination:: |
public | function | ||
MigrateDestination:: |
public | function | ||
MigrateDestination:: |
public | function | Reset numCreated and numUpdated back to 0. | |
MigrateDestinationEntity:: |
protected | property | The bundle (node type, vocabulary, etc.) of the destination. | |
MigrateDestinationEntity:: |
protected | property | The entity type (node, user, taxonomy_term, etc.) of the destination. | |
MigrateDestinationEntity:: |
protected | property | Default language for text fields in this destination. | |
MigrateDestinationEntity:: |
protected | property | Default input format for text fields in this destination. | |
MigrateDestinationEntity:: |
public static | function | Flattens an array of allowed values. | |
MigrateDestinationEntity:: |
public | function | Give handlers a shot at modifying the object (or taking additional action) after saving it. | |
MigrateDestinationEntity:: |
public | function | Give handlers a shot at cleaning up after an entity has been rolled back. | |
MigrateDestinationEntity:: |
public static | function | 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. | |
MigrateDestinationEntity:: |
public | function | ||
MigrateDestinationEntity:: |
public | function | ||
MigrateDestinationEntity:: |
public | function | ||
MigrateDestinationEntity:: |
public | function | ||
MigrateDestinationEntity:: |
public | function | Give handlers a shot at modifying the object before saving it. | |
MigrateDestinationEntity:: |
public | function | Give handlers a shot at cleaning up before an entity has been rolled back. | |
MigrateDestinationEntity:: |
public | function |
Derived classes must implement __toString(). Overrides MigrateDestination:: |
|
MigrateDestinationRestrictions:: |
protected | property | ||
MigrateDestinationRestrictions:: |
public | function |
Returns a list of fields available to be mapped for the node type (bundle) Overrides MigrateDestination:: |
|
MigrateDestinationRestrictions:: |
public static | function | ||
MigrateDestinationRestrictions:: |
public | function |
Import a single node. Overrides MigrateDestination:: |
|
MigrateDestinationRestrictions:: |
public | function | ||
MigrateDestinationRestrictions:: |
public | function |
Simply save the key schema. Overrides MigrateDestinationEntity:: |