EmptySource.php

Same filename in this branch
  1. 8.9.x core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php
Same filename in other branches
  1. 9 core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php
  2. 9 core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
  3. 10 core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php
  4. 10 core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
  5. 11.x core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php
  6. 11.x core/modules/migrate/src/Plugin/migrate/source/EmptySource.php

Namespace

Drupal\migrate\Plugin\migrate\source

File

core/modules/migrate/src/Plugin/migrate/source/EmptySource.php

View source
<?php

namespace Drupal\migrate\Plugin\migrate\source;


/**
 * Source returning a row based on the constants provided.
 *
 * Example:
 *
 * @code
 * source:
 *   plugin: empty
 *   constants:
 *     entity_type: user
 *     field_name: image
 * @endcode
 *
 * This will return a single row containing 'entity_type' and 'field_name'
 * elements, with values of 'user' and 'image', respectively.
 *
 * @MigrateSource(
 *   id = "empty",
 *   source_module = "migrate"
 * )
 */
class EmptySource extends SourcePluginBase {
    
    /**
     * {@inheritdoc}
     */
    public function fields() {
        return [
            'id' => t('ID'),
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    public function initializeIterator() {
        return new \ArrayIterator([
            [
                'id' => '',
            ],
        ]);
    }
    
    /**
     * Allows class to decide how it will react when it is treated like a string.
     */
    public function __toString() {
        return '';
    }
    
    /**
     * {@inheritdoc}
     */
    public function getIds() {
        $ids['id']['type'] = 'string';
        return $ids;
    }
    
    /**
     * {@inheritdoc}
     */
    public function count($refresh = FALSE) {
        return 1;
    }

}

Classes

Title Deprecated Summary
EmptySource Source returning a row based on the constants provided.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.