Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add skipFieldHandles config setting #860

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/services/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,19 @@ public function processFeed($step, $feed, &$processedElementIds)
// Set the attributes for the element
$element->setAttributes($attributeData, false);

// We can opt-out of populating certain fields
$skipFieldHandles = Plugin::$plugin->service->getConfig('skipFieldHandles', $feed['id']);

if ($skipFieldHandles) {
$feed['fieldMapping'] = array_filter($feed['fieldMapping'], function ($fieldInfo, $fieldHandle) use ($skipFieldHandles) {
$skip = in_array($fieldHandle, $skipFieldHandles);
if ($skip) {
Plugin::info('Skipped `{field}` due to config setting.', ['field' => $fieldHandle]);
}
return !$skip;
}, ARRAY_FILTER_USE_BOTH);
}

// Then, do the same for custom fields. Again, this should be done after populating the element attributes
foreach ($feed['fieldMapping'] as $fieldHandle => $fieldInfo) {
if (Hash::get($fieldInfo, 'field')) {
Expand Down