Guest User

Untitled

a guest
Jul 15th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Drupal\migrate_nbr\Plugin\migrate\destination;
  4.  
  5. use Drupal\migrate\Plugin\MigrationInterface;
  6. use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
  7. use Drupal\migrate\Row;
  8.  
  9. /**
  10. * Provides noop destination plugin.
  11. *
  12. * Sometimes you want to use the migrate system for more, or less, that it was
  13. * designed for and this means not having anything to do in the destination
  14. * plugin. e.g. your migration is too far in to back out and you need to 'fix'
  15. * something. A quick lightweight migration where the work happens in the
  16. * process section could do this.
  17. *
  18. * This destination plugin is a 'quickfix' to the `null` destination plugin
  19. * always throwing false for `requirements_met`. I think this also sounds more
  20. * 'correct' in describing what the plugin does.
  21. *
  22. * @MigrateDestination(
  23. * id = "noop"
  24. * )
  25. */
  26. class NoOp extends DestinationBase {
  27.  
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) {
  32. parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
  33. $this->supportsRollback = FALSE;
  34. }
  35.  
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function getIds() {
  40. return [];
  41. }
  42.  
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function fields(MigrationInterface $migration = NULL) {
  47. return [];
  48. }
  49.  
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function import(Row $row, array $old_destination_id_values = []) {
  54. // The no-op always succeeds. Returning TRUE here prevents a 'failed'
  55. // being thrown. However, it also gives no indication of progress.
  56. return TRUE;
  57. }
  58.  
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function saveIdMapping(Row $row, array $destination_id_values, $source_row_status = MigrateIdMapInterface::STATUS_IMPORTED, $rollback_action = MigrateIdMapInterface::ROLLBACK_DELETE) {
  63. // Do nothing.
  64. }
  65.  
  66. }
Add Comment
Please, Sign In to add comment