123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace Drupal\reinstall\Plugin\migrate\source;
- use Drupal\migrate\Plugin\MigrationInterface;
- /**
- * Source plugin for users from a YAML file.
- *
- * @MigrateSource(
- * id = "reinstall_users"
- * )
- */
- class ReinstallUserSource extends SimpleSource {
- /**
- * Constructor.
- */
- public function __construct(
- array $configuration,
- string $pluginId,
- array $pluginDefinition,
- MigrationInterface $migration
- ) {
- parent::__construct($configuration, $pluginId, $pluginDefinition, $migration);
- $rawRecords = array_map([$this, 'flattenRecord'], $this->initialParse($configuration));
- $rawRecords = array_filter($rawRecords, [$this, 'filter01']);
- $this->records = $rawRecords;
- }
- /**
- * Skip users 0 and 1 in imports, as they are core-provided.
- *
- * @param array $record
- * The description of a user entity.
- *
- * @return bool
- * Include it (1) or filter it (0).
- */
- protected function filter01(array $record) {
- return ($record['uid'] ?? 0) > 1;
- }
- }
|