EmptySource.php

Same filename in this branch
  1. 8.9.x core/modules/migrate/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_drupal\Plugin\migrate\source

File

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

View source
<?php

namespace Drupal\migrate_drupal\Plugin\migrate\source;

use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Entity\DependencyTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\migrate\source\EmptySource as BaseEmptySource;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;

/**
 * Source returning an empty row with Drupal specific config dependencies.
 *
 * @MigrateSource(
 *   id = "md_empty",
 *   source_module = "system",
 * )
 */
class EmptySource extends BaseEmptySource implements ContainerFactoryPluginInterface, DependentPluginInterface {
    use DependencyTrait;
    use DeprecatedServicePropertyTrait;
    
    /**
     * {@inheritdoc}
     */
    protected $deprecatedProperties = [
        'entityManager' => 'entity.manager',
    ];
    
    /**
     * The entity type manager.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;
    
    /**
     * {@inheritdoc}
     */
    public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityTypeManagerInterface $entity_manager) {
        parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
        $this->entityTypeManager = $entity_manager;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
        return new static($configuration, $plugin_id, $plugin_definition, $migration, $container->get('entity_type.manager'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function calculateDependencies() {
        // The empty source plugin supports the entity_type constant.
        if (isset($this->configuration['constants']['entity_type'])) {
            $this->addDependency('module', $this->entityTypeManager
                ->getDefinition($this->configuration['constants']['entity_type'])
                ->getProvider());
        }
        return $this->dependencies;
    }

}

Classes

Title Deprecated Summary
EmptySource Source returning an empty row with Drupal specific config dependencies.

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