Updated to Drupal 8.5. Core Media not yet in use.
[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 a row based on the constants provided.
7  *
8  * Example:
9  *
10  * @code
11  * source:
12  *   plugin: empty
13  *   constants:
14  *     entity_type: user
15  *     field_name: image
16  * @endcode
17  *
18  * This will return a single row containing 'entity_type' and 'field_name'
19  * elements, with values of 'user' and 'image', respectively.
20  *
21  * @MigrateSource(
22  *   id = "empty"
23  * )
24  */
25 class EmptySource extends SourcePluginBase {
26
27   /**
28    * {@inheritdoc}
29    */
30   public function fields() {
31     return [
32       'id' => t('ID'),
33     ];
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function initializeIterator() {
40     return new \ArrayIterator([['id' => '']]);
41   }
42
43   /**
44    * Allows class to decide how it will react when it is treated like a string.
45    */
46   public function __toString() {
47     return '';
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function getIds() {
54     $ids['id']['type'] = 'string';
55     return $ids;
56   }
57
58   /**
59    * {@inheritdoc}
60    */
61   public function count($refresh = FALSE) {
62     return 1;
63   }
64
65 }