public function FieldFormatterContext::iResetTheFormatterOfTheFieldOfTheBundleOfEntity in Views field formatter 8.2
Reset a formatter.
@Given I reset the formatter of the :field field of the :bundle bundle of :entity entity @Given I reset the formatter of the :field field of the :bundle bundle of :entity entity in :view_mode view mode
File
- tests/
Behat/ FieldFormatterContext.php, line 76
Class
- FieldFormatterContext
- Class FieldFormatterContext.
Namespace
Drupal\Tests\views_field_formatter\BehatCode
public function iResetTheFormatterOfTheFieldOfTheBundleOfEntity($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();
if (!isset($config['content'][$field]) || !isset($config['hidden'][$field])) {
// @todo Throw an error.
return;
}
$region = isset($config['content'][$field]) ? 'content' : 'hidden';
if (!\is_array($config[$region][$field])) {
$config[$region][$field] = [
'type' => NULL,
'settings' => [],
'third_party_settings' => [],
];
}
else {
$config[$region][$field]['type'] = NULL;
$config[$region][$field]['settings'] = [];
$config[$region][$field]['third_party_settings'] = [];
}
\Drupal::configFactory()
->getEditable($config_name)
->setData($config)
->save();
}