public function ChangeFieldInfo::processSettings in Business Rules 8
Same name and namespace in other branches
- 2.x src/Plugin/BusinessRulesAction/ChangeFieldInfo.php \Drupal\business_rules\Plugin\BusinessRulesAction\ChangeFieldInfo::processSettings()
Process the item settings before it's saved.
Parameters
array $settings: The settings to be processed before save the Business Rule Item.
\Drupal\business_rules\ItemInterface $item: The item being processed.
Return value
array The processed settings.
Overrides BusinessRulesItemPluginBase::processSettings
File
- src/
Plugin/ BusinessRulesAction/ ChangeFieldInfo.php, line 278
Class
- ChangeFieldInfo
- Class ChangeFieldInfo.
Namespace
Drupal\business_rules\Plugin\BusinessRulesActionCode
public function processSettings(array $settings, ItemInterface $item) {
if ($item
->isNew()) {
return [];
}
if (count($item
->getSettings('fields'))) {
$settings['fields'] += $item
->getSettings('fields');
}
if ($settings['fields']['new.field']['field'] && $settings['fields']['new.field']['action']) {
$availableFields = $this->util
->getBundleEditableFields($item
->getTargetEntityType(), $item
->getTargetBundle());
$id = $settings['fields']['new.field']['field'] . '__' . $settings['fields']['new.field']['action'];
$settings['fields'][$id] = $settings['fields']['new.field'];
$settings['fields'][$id]['id'] = $id;
uasort($settings['fields'], function ($a, $b) use ($availableFields) {
return $availableFields[$a['field']] > $availableFields[$b['field']] ? 1 : -1;
});
}
unset($settings['fields']['new.field']);
return $settings;
}