12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace Drupal\reinstall\Plugin\migrate\source;
- use Drupal\migrate\Plugin\MigrationInterface;
- use Drupal\migrate\Row;
- /**
- * Source plugin for terms 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));
- $records = array_filter($rawRecords, [$this, 'filter01']);
- $this->records = $records;
- }
- protected function flattenRecord($record) {
- $row = new Row($record);
- $this->flattenRow($row);
- return $row->getSource();
- }
- protected function filter01($record) {
- return ($record['uid'] ?? 0) > 1;
- }
- /**
- * {@inheritdoc}
- */
- public function fields() {
- $ret = [
- 'uid' => 'User ID',
- 'uuid' => 'UUID',
- 'langcode' => 'ISO 639 language code',
- 'preferred_langcode' => 'ISO 639 preferred language code',
- 'preferred_admin_langcode' => 'ISO 639 preferred administrative language code',
- 'name' => 'The user name (PK)',
- 'mail' => 'The current user e-mail address',
- 'timezone' => 'The user timezone',
- 'status' => 'The user status',
- 'access' => 'Latest access timestamp',
- 'login' => 'Latest login timestamp',
- 'init' => 'Initial user e-mail address',
- 'created' => 'User creation timestamp',
- 'changed' => 'Modification timestamp',
- 'default_langcode' => 'ISO 639 default language code',
- ];
- return $ret;
- }
- /**
- * {@inheritdoc}
- */
- public function getIds() {
- $ids = [
- 'uid' => [
- 'type' => 'integer',
- ],
- ];
- return $ids;
- }
- }
|