You are here

public function FieldFormatterContext::iEnableTheDisplayOfTheFieldOfTheBundleOfEntity in Views field formatter 8.2

Enable a field in the entity view.

@Given I enable the display of the :field field of the :bundle bundle of :entity entity @Given I enable the display of the :field field of the :bundle bundle of :entity entity in :view_mode view mode

File

tests/Behat/FieldFormatterContext.php, line 20

Class

FieldFormatterContext
Class FieldFormatterContext.

Namespace

Drupal\Tests\views_field_formatter\Behat

Code

public function iEnableTheDisplayOfTheFieldOfTheBundleOfEntity($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();
  unset($config['hidden'][$field]);
  $config['content'][$field] = [
    'region' => 'content',
    'type' => NULL,
    'settings' => [],
    'third_party_settings' => [],
  ];
  \Drupal::configFactory()
    ->getEditable($config_name)
    ->setData($config)
    ->save();
}