Created
June 19, 2018 20:44
-
-
Save brooke-heaton/09c702f4f1b02fd0fb54011ecd648432 to your computer and use it in GitHub Desktop.
Drupal 8 Event Subscriber to trigger a function to drop a mySql table and import data from a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Contains \Drupal\migrate\Event\MigrateEvent. | |
*/ | |
namespace Drupal\my_migration\Event; | |
use Drupal\migrate\Event\MigrateEvents; | |
use Drupal\migrate\Event\MigrateImportEvent; | |
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
class MyMigrationMigrationEventSubscriber implements EventSubscriberInterface { | |
/** | |
* {@inheritdoc} | |
*/ | |
static function getSubscribedEvents() { | |
$events[MigrateEvents::PRE_IMPORT][] = ['preImport']; | |
return $events; | |
} | |
public function preImport(MigrateImportEvent $event) { | |
if ($event->getMigration()->getPluginId() === 'section' || 'subject') { | |
my_migration_refresh_tables(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment