You are here

public function WordPressAttachment::__construct in WordPress Migrate 7.2

Same name and namespace in other branches
  1. 7 wordpress_attachment.inc \WordPressAttachment::__construct()

Set it up

Overrides WordPressMigration::__construct

File

./wordpress_attachment.inc, line 43

Class

WordPressAttachment
Implementation of WordPressMigration, for attachments

Code

public function __construct(array $arguments = array()) {
  parent::__construct($arguments);

  // Construct the source object.
  $this->source = new WordPressAttachmentSource($this->wxrFile, $this->machineName);
  $this->destination = new MigrateDestinationFile();

  // post_id is the unique ID of items in WordPress
  $this->map = new MigrateSQLMap($this->machineName, array(
    'wp:post_id' => array(
      'type' => 'int',
      'not null' => TRUE,
      'unsigned' => TRUE,
      'description' => 'WordPress post ID',
    ),
  ), MigrateDestinationFile::getKeySchema());
  $this
    ->addFieldMapping('value', 'wp:attachment_url')
    ->xpath('wp:attachment_url');
  $this
    ->addFieldMapping('destination_file', 'wp:attachment_url')
    ->xpath('wp:attachment_url')
    ->callbacks(array(
    $this,
    'fixDestinationFile',
  ));
  $this
    ->addFieldMapping('uid', 'dc:creator')
    ->xpath('dc:creator')
    ->description('Use matching username if any, otherwise current user');
  $this
    ->addFieldMapping('timestamp', 'wp:post_date')
    ->xpath('wp:post_date');
  $this
    ->addFieldMapping(NULL, 'wp:post_parent')
    ->xpath('wp:post_parent')
    ->description('Mapping is handled dynamically');

  // Unmapped destination fields
  $this
    ->addUnmigratedDestinations(array(
    'destination_dir',
    'file_replace',
    'preserve_files',
    'source_dir',
  ));

  // Unmapped source fields
  $this
    ->addUnmigratedSources(array(
    'link',
    'guid',
    'description',
    'excerpt:encoded',
    'wp:post_id',
    'wp:comment_status',
    'wp:ping_status',
    'wp:post_name',
    'wp:status',
    'wp:menu_order',
    'wp:post_type',
    'wp:post_password',
    'wp:is_sticky',
    'tag',
    'category',
    '_wp_attached_file',
    '_wp_attachment_metadata',
    'title',
    'content:encoded',
  ));
  $this
    ->addFieldMapping(NULL, 'pubDate')
    ->description('Use post_date')
    ->issueGroup(t('DNM'));
  $this
    ->addFieldMapping(NULL, 'wp:post_date_gmt')
    ->description('Use post_date')
    ->issueGroup(t('DNM'));
}