diff --git a/includes/migrate/plugins/destinations/og_membership.inc b/includes/migrate/plugins/destinations/og_membership.inc index 3af3b70..c5ee57b 100644 --- a/includes/migrate/plugins/destinations/og_membership.inc +++ b/includes/migrate/plugins/destinations/og_membership.inc @@ -8,7 +8,11 @@ /** * Destination class implementing migration into an OG Audience field. */ -class MigrateDestinationOGMembership extends MigrateDestination { +class MigrateDestinationOGMembership extends MigrateDestinationEntity { + + public function __construct($bundle = OG_MEMBERSHIP_TYPE_DEFAULT, array $options = array()) { + parent::__construct('og_membership', $bundle, $options); + } public function __toString() { return t('og-membership'); @@ -113,57 +117,8 @@ class MigrateDestinationOGMembership extends MigrateDestination { return array($og_membership->id); } - /** - * Give handlers a shot at modifying the object before saving it. - * - * @param $entity - * OGMembership object to build. Prefilled with any fields mapped in - * the Migration. - * @param $source_row - * Raw source data object - passed through to prepare handlers. - */ - public function prepare($entity, stdClass $row) { - // We do nothing here but allow child classes to act. - $migration = Migration::currentMigration(); - $entity->migrate = array( - 'machineName' => $migration->getMachineName(), - ); - - // Call any general handlers. - migrate_handler_invoke_all('og_membership', 'prepare', $entity, $row); - // Then call any prepare handler for this specific Migration. - if (method_exists($migration, 'prepare')) { - $migration->prepare($entity, $row); - } - } - - /** - * Give handlers a shot at modifying the object (or taking additional action) - * after saving it. - * - * @param $entity - * OGMembership object to build. This is the complete object after - * saving. - * @param $source_row - * Raw source data object - passed through to complete handlers. - */ - public function complete($entity, stdClass $row) { - // We do nothing here but allow child classes to act. - $migration = Migration::currentMigration(); - $entity->migrate = array( - 'machineName' => $migration->getMachineName(), - ); - - // Call any general handlers. - migrate_handler_invoke_all('og_membership', 'complete', $entity, $row); - // Then call any complete handler for this specific Migration. - if (method_exists($migration, 'complete')) { - $migration->complete($entity, $row); - } - } - - public function fields() { - return array( + public function fields($migration = NULL) { + $fields = array( 'group_type' => 'Group entity type', 'gid' => 'Group entity id', 'entity_type' => 'Entity type', @@ -173,5 +128,10 @@ class MigrateDestinationOGMembership extends MigrateDestination { 'is_admin' => 'Legacy: Is member an administrator in this group. Defaults to No.', 'group_roles' => 'Array of role names to assign to the user in this group.', ); + + // Then add in anything provided by handlers + $fields += migrate_handler_invoke_all('Entity', 'fields', $this->entityType, $this->bundle, $migration); + $fields += migrate_handler_invoke_all('OGMembership', 'fields', $this->entityType, $this->bundle, $migration); + return $fields; } }