Less commonly implemented Migration methods

pre/post Import/Rollback methods

You can execute code before or after an import or rollback operation by implementing the Migration class methods preImport(), postImport(), preRollback(), or postRollback(). Each of these is called once per individual Migration - that is, if you implement preImport() in an article node migration class, it will be called after any previous migrations you're running, and immediately before the first row of your article node migration is called.

Typical actions can be the enabling / disabling of certain modules or changing configurations.

class ArticleMigration implements Migration {
...
  public function preImport() {
    parent::preImport();
    // Code to execute before first article row is imported
  }
...
  public function postImport() {
    parent::postImport();
    // Code to execute after the last article row has been imported
  }
...
  public function preRollback() {
    parent::preRollback();
    // Code to execute before first article row is deleted
  }
...
  public function postRollback() {
    parent::postRollback();
    // Code to execute after the last article row has been deleted
  }

A practical example can be found here.

Subscribe with RSS Subscribe to RSS - rollback