2017-02-28 127 views
0

我正嘗試將文件遷移到具有大量自定義字段的自定義文件類型中。但是,它們似乎正在以document文件類型遷移,而不是遷移到我自定義創建的文件類型中。Drupal 7 - 將文件遷移到自定義文件類型

我使用的MigrateDestinationFile作爲我的目標是這樣的:

$this->destination = new MigrateDestinationFile(); 

我試圖映射typethis answer建議是這樣的:

$this->addFieldMapping('type')->defaultValue('custom_file_type'); 

此解決方案不起作用,當檢查MigrateDestinationFile的可映射字段時,沒有指定type字段,所以我認爲這是該解決方案無法工作的原因。

如果有人能指出我如何遷移到一個自定義文件類型的例子,將不勝感激。也許我使用了錯誤的destination?或者我錯過了一些非常明顯的東西。

遷移的其他部分對此問題無關緊要。

回答

0

顯然我有兩個問題。第一個是當我們創建文件類型時,我們稱之爲file,由於某些原因,您不能將其設置爲遷移目標,因爲它在MigrateDestinationFile構造函數中已經是默認值(請參閱下面的代碼)。

From file.inc:544 

/** 
* Basic initialization 
* 
* @param array $options 
* Options applied to files.  
*/ 
public function __construct($bundle = 'file', $file_class = 'MigrateFileUri', $options = array()) { 
    parent::__construct('file', $bundle, $options); 
    $this->fileClass = $file_class; 
} 

第二個問題是映射到外地本身。我只是不得不重新創建文件類型使用不同的名稱後設置正確的目標是這樣的:

$this->destination = new MigrateDestinationFile('product_download'); 

做這其中正確的內容類型,而不是document文件類型創建遷移文件之後。