public function FieldFormatterContext::iSetTheFormatterToTheFieldOfTheBundleOfEntity in Views field formatter 8.2
Set a specific formatter to a field.
@Given I set the :formatter formatter to the field :field of the :bundle bundle of :entity entity @Given I set the :formatter formatter to the :field field of the :bundle bundle of :entity entity in :view_mode view mode
File
- tests/
Behat/ FieldFormatterContext.php, line 115
Class
- FieldFormatterContext
- Class FieldFormatterContext.
Namespace
Drupal\Tests\views_field_formatter\BehatCode
public function iSetTheFormatterToTheFieldOfTheBundleOfEntity($formatter, $field, $bundle, $entity, $view_mode = 'default') {
$config_name = \sprintf('core.entity_view_display.%s.%s.%s', $entity, $bundle, $view_mode);
$config = \Drupal::configFactory()
->getEditable($config_name)
->getRawData();
$config['content'][$field] = [
'region' => 'content',
'type' => $formatter,
'settings' => [],
'third_party_settings' => [],
];
\Drupal::configFactory()
->getEditable($config_name)
->setData($config)
->save();
}