You are here

class PreRowSave in Commerce Migrate 3.0.x

Same name in this branch
  1. 3.0.x modules/magento/src/EventSubscriber/PreRowSave.php \Drupal\commerce_migrate_magento\EventSubscriber\PreRowSave
  2. 3.0.x modules/ubercart/src/EventSubscriber/PreRowSave.php \Drupal\commerce_migrate_ubercart\EventSubscriber\PreRowSave
Same name and namespace in other branches
  1. 8.2 modules/ubercart/src/EventSubscriber/PreRowSave.php \Drupal\commerce_migrate_ubercart\EventSubscriber\PreRowSave
  2. 3.1.x modules/ubercart/src/EventSubscriber/PreRowSave.php \Drupal\commerce_migrate_ubercart\EventSubscriber\PreRowSave

Handles order and order variation references.

@package \Drupal\commerce_migrate\EventSubscriber

Hierarchy

  • class \Drupal\commerce_migrate_ubercart\EventSubscriber\PreRowSave implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of PreRowSave

1 string reference to 'PreRowSave'
commerce_migrate_ubercart.services.yml in modules/ubercart/commerce_migrate_ubercart.services.yml
modules/ubercart/commerce_migrate_ubercart.services.yml
1 service uses PreRowSave
commerce_migrate.ubercart.migrate_pre_row_save in modules/ubercart/commerce_migrate_ubercart.services.yml
Drupal\commerce_migrate_ubercart\EventSubscriber\PreRowSave

File

modules/ubercart/src/EventSubscriber/PreRowSave.php, line 16

Namespace

Drupal\commerce_migrate_ubercart\EventSubscriber
View source
class PreRowSave implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[MigrateEvents::PRE_ROW_SAVE][] = 'onPreRowSave';
    return $events;
  }

  /**
   * Reacts to the PRE_ROW_SAVE event.
   *
   * If the profile exists, then set it as a new revision.
   *
   * @param \Drupal\migrate\Event\MigratePreRowSaveEvent $event
   *   The event object.
   */
  public function onPreRowSave(MigratePreRowSaveEvent $event) {
    $migration = $event
      ->getMigration();
    $source_plugin = $migration
      ->getSourcePlugin();
    if (is_a($source_plugin, ProfileBilling::class)) {
      if ($profile_id = $event
        ->getRow()
        ->getDestinationProperty('profile_id')) {
        if ($profile = ProfileEntity::load($profile_id)) {
          $profile
            ->setNewRevision();
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PreRowSave::getSubscribedEvents public static function
PreRowSave::onPreRowSave public function Reacts to the PRE_ROW_SAVE event.