1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace Drupal\reinstall\EventSubscriber;
- use Drupal\migrate\Event\MigrateEvents;
- use Drupal\migrate\Event\MigrateImportEvent;
- use Symfony\Component\EventDispatcher\EventSubscriberInterface;
- class UserPreImport implements EventSubscriberInterface {
- public static function getSubscribedEvents() {
- return [
- MigrateEvents::PRE_IMPORT => 'onPreImport',
- ];
- }
- public function onPreImport(MigrateImportEvent $event) {
- /** @var \Drupal\reinstall\Plugin\migrate\source\ReinstallUserSource $plugin */
- $plugin = $event->getMigration()->getSourcePlugin();
- $plugin->records = array_filter($plugin->records, [$this, 'filter01']);
- return;
- }
- /**
- * 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).
- */
- public function filter01(array $record) {
- $ret = ($record['uid'] ?? 0) > 1;
- return $ret;
- }
- }
|