/**
  * Listener for migration imports.
  */
 public function onMigrateImport(MigrateImportEvent $event)
 {
     $migration = $event->getMigration();
     $configuration = $migration->getDestinationConfiguration();
     $entity_types = NestedArray::getValue($configuration, ['content_translation_update_definitions']);
     if ($entity_types) {
         $entity_types = array_intersect_key($this->entityManager->getDefinitions(), array_flip($entity_types));
         $this->updateDefinitions($entity_types);
     }
 }
Exemplo n.º 2
0
 /**
  * Test logging a message.
  *
  * @covers ::__construct
  * @covers ::logMessage
  */
 public function testLogMessage()
 {
     $migration = $this->prophesize('\\Drupal\\migrate\\Plugin\\MigrationInterface');
     $message_service = $this->prophesize('\\Drupal\\migrate\\MigrateMessageInterface');
     $event = new MigrateImportEvent($migration->reveal(), $message_service->reveal());
     // Assert that the intended calls to the services happen.
     $message_service->display('status message', 'status')->shouldBeCalledTimes(1);
     $event->logMessage('status message');
     $message_service->display('warning message', 'warning')->shouldBeCalledTimes(1);
     $event->logMessage('warning message', 'warning');
 }
Exemplo n.º 3
0
 /**
  * Tries to invoke event handling methods on source and destination plugins.
  *
  * @param string $method
  *   The method to invoke.
  * @param \Drupal\migrate\Event\MigrateImportEvent|\Drupal\migrate\Event\MigrateRollbackEvent $event
  *   The event that has triggered the invocation.
  * @param string $plugin_interface
  *   The interface which plugins must implement in order to be invoked.
  */
 protected function invoke($method, $event, $plugin_interface)
 {
     $migration = $event->getMigration();
     $source = $migration->getSourcePlugin();
     if ($source instanceof $plugin_interface) {
         call_user_func([$source, $method], $event);
     }
     $destination = $migration->getDestinationPlugin();
     if ($destination instanceof $plugin_interface) {
         call_user_func([$destination, $method], $event);
     }
 }
 /**
  * @param \Drupal\migrate\Event\MigrateImportEvent $event
  */
 public function onMigratePostImport(MigrateImportEvent $event)
 {
     if ('basic_block' === $event->getMigration()->get('id')) {
         $files = ['block.block.callforpaper.yml', 'block.block.featuredfirst.yml', 'block.block.featuredsecond.yml', 'block.block.featuredthird.yml', 'block.block.mentorship.yml', 'block.block.training.yml'];
         foreach ($files as $file) {
             $base_path = $this->moduleHandler->getModule('ddd_fixtures')->getPath();
             $contents = @file_get_contents($base_path . '/sources/block_configs/' . $file);
             $config_name = basename('sources/block_configs/' . $file, '.yml');
             $data = (new InstallStorage())->decode($contents);
             $this->configFactory->getEditable($config_name)->setData($data)->save();
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Reacts to post-import event.
  *
  * @param \Drupal\Migrate\Event\MigrateImportEvent $event
  *   The migration event.
  * @param string $name
  *   The event name.
  */
 public function postImportEventRecorder(MigrateImportEvent $event, $name)
 {
     $this->state->set('migrate_events_test.post_import_event', array('event_name' => $name, 'migration' => $event->getMigration()));
 }
 /**
  * React to migration completion.
  *
  * @param \Drupal\migrate\Event\MigrateImportEvent $event
  *   The map event.
  */
 public function onPostImport(MigrateImportEvent $event)
 {
     $migrate_last_imported_store = \Drupal::keyValue('migrate_last_imported');
     $migrate_last_imported_store->set($event->getMigration()->id(), round(microtime(TRUE) * 1000));
     $this->progressMessage();
     $this->removeListeners();
 }
Exemplo n.º 7
0
 /**
  * React to migration completion.
  *
  * @param \Drupal\migrate\Event\MigrateImportEvent $event
  *   The map event.
  */
 public function onPostImport(MigrateImportEvent $event)
 {
     $migrate_last_imported_store = \Drupal::keyValue('migrate_last_imported');
     $migrate_last_imported_store->set($event->getMigration()->id(), round(microtime(TRUE) * 1000));
     $this->progressMessage();
     foreach ($this->listeners as $event => $listener) {
         \Drupal::service('event_dispatcher')->removeListener($event, $listener);
     }
 }