2391b0a2514b902daabec46ed3798412b65be2cb
[yaffs-website] / web / core / modules / migrate / src / Plugin / migrate / source / EmptySource.php
1 <?php
2
3 namespace Drupal\migrate\Plugin\migrate\source;
4
5 /**
6  * Source returning an empty row.
7  *
8  * This is generally useful when needing to create a field using a migration..
9  *
10  * @MigrateSource(
11  *   id = "empty"
12  * )
13  */
14 class EmptySource extends SourcePluginBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function fields() {
20     return [
21       'id' => t('ID'),
22     ];
23   }
24
25   /**
26    * {@inheritdoc}
27    */
28   public function initializeIterator() {
29     return new \ArrayIterator([['id' => '']]);
30   }
31
32   /**
33    * Allows class to decide how it will react when it is treated like a string.
34    */
35   public function __toString() {
36     return '';
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function getIds() {
43     $ids['id']['type'] = 'string';
44     return $ids;
45   }
46
47   /**
48    * {@inheritdoc}
49    */
50   public function count() {
51     return 1;
52   }
53
54 }