EmptySource.php 847 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
<?php

/**
 * @file
 * Contains \Drupal\migrate\Plugin\migrate\source\Constants.
 */

namespace Drupal\migrate\Plugin\migrate\source;

/**
 * Source returning an empty row.
 *
 * This is generally useful when needing to create a field using a migration..
 *
 * @MigrateSource(
 *   id = "empty"
 * )
 */
class EmptySource extends SourcePluginBase {

  /**
   * {@inheritdoc}
   */
  public function fields() {
    return array(
      'id' => t('ID'),
    );
  }

  /**
   * {@inheritdoc}
   */
33
  public function initializeIterator() {
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    return new \ArrayIterator(array(array('id' => '')));
  }

  public function __toString() {
    return '';
  }

  /**
   * {@inheritdoc}
   */
  public function getIds() {
    $ids['id']['type'] = 'string';
    return $ids;
  }

  /**
   * {@inheritdoc}
   */
  public function count() {
    return 1;
  }

}