public function UserFeed::afterParse in Feeds 8.3
Acts on parser result.
File
- tests/
modules/ feeds_test_alter_source/ src/ EventSubscriber/ UserFeed.php, line 28
Class
- UserFeed
- Alters the parsed result for the feeds importing users.
Namespace
Drupal\feeds_test_alter_source\EventSubscriberCode
public function afterParse(ParseEvent $event) {
if ($event
->getFeed()
->getType()
->id() != 'user_import') {
// Not interested in this feed. Abort.
return;
}
/** @var \Drupal\feeds\Feeds\Item\ItemInterface $item */
foreach ($event
->getParserResult() as $item) {
// Convert roles value to multiple values.
foreach ([
'role_ids',
'role_labels',
] as $source_name) {
$data = $item
->get($source_name);
if (!empty($data)) {
$item
->set($source_name, explode('|', $data));
}
}
}
}