UserFeed.php in Feeds 8.3
File
tests/modules/feeds_test_alter_source/src/EventSubscriber/UserFeed.php
View source
<?php
namespace Drupal\feeds_test_alter_source\EventSubscriber;
use Drupal\feeds\Event\FeedsEvents;
use Drupal\feeds\Event\ParseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class UserFeed implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return [
FeedsEvents::PARSE => [
[
'afterParse',
FeedsEvents::AFTER,
],
],
];
}
public function afterParse(ParseEvent $event) {
if ($event
->getFeed()
->getType()
->id() != 'user_import') {
return;
}
foreach ($event
->getParserResult() as $item) {
foreach ([
'role_ids',
'role_labels',
] as $source_name) {
$data = $item
->get($source_name);
if (!empty($data)) {
$item
->set($source_name, explode('|', $data));
}
}
}
}
}
Classes
Name |
Description |
UserFeed |
Alters the parsed result for the feeds importing users. |