Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.77 KB | None | 0 0
  1. codeon_migrate.info
  2. -----------------------------
  3.  
  4. name = CodeOn Migrate
  5. description = CodeOn Test Data Migration
  6. core = 7.x
  7. package = CodeOn
  8. version = 7.x-1.0
  9. project = codeon_migrate
  10. dependencies[] = migrate
  11.  
  12. files[] = migrate_codeon.migrate.inc
  13. files[] = testimonials.inc
  14.  
  15.  
  16.  
  17. migrate_codeon.migrate.inc
  18. -------------------------------
  19.  
  20. /**
  21.  * Implements hook_migrate_api().
  22.  */
  23. function migrate_codeon_migrate_api() {
  24.  
  25.     $api = array(
  26.         'api' => 2,
  27.         'groups' => array(
  28.             'CodeOn' => array(
  29.                 'title' => t('CodeOn Test Data Migrations'),
  30.             ),
  31.         ),
  32.         'migrations' => array(
  33.             'CodeOnTestimonials' => array(
  34.                 'class_name' => 'TestimonialsMigration',
  35.                 'group_name' => 'CodeOn',
  36.             ),
  37.         ),
  38.     );
  39.     return $api;
  40. }
  41.  
  42.  
  43. testimonials.inc
  44. -------------------------------
  45.  
  46. class TestimonialsMigration extends Migration {
  47.     public function __construct($arguments) {
  48.  
  49.         parent::__construct($arguments);
  50.  
  51.         $query = Database::getConnection('default', 'legacy')
  52.             ->select('example_pages')
  53.             ->fields('example_pages', array('pgid', 'page_title', 'page_body'));
  54.  
  55.         $this->source = new MigrateSourceSQL($query);
  56.         $this->destination = new MigrateDestinationNode('page');
  57.  
  58.         $this->map = new MigrateSQLMap($this->machineName,
  59.             array(
  60.                 'pgid' => array('type' => 'int',
  61.                     'unsigned' => TRUE,
  62.                     'not null' => TRUE,
  63.                 )
  64.             ),
  65.             MigrateDestinationNode::getKeySchema()
  66.         );
  67.  
  68.         $this->addFieldMapping('title', 'page_title');
  69.         $this->addFieldMapping('body', 'page_body');
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement