You are here

protected function RangeTestTrait::setViewDisplayComponent in Range 8

Sets the display settings for a default view display.

Parameters

string $field_type: Range field type. Could be one of the following values: range_integer, range_float or range_decimal.

string $display_type: Range field display type. Could be one of the following values: range_integer, range_decimal or range_unformatted.

array $settings: Array of display settings.

File

tests/src/Traits/RangeTestTrait.php, line 254

Class

RangeTestTrait
Provides helper methods to test range fields.

Namespace

Drupal\Tests\range\Traits

Code

protected function setViewDisplayComponent($field_type = 'range_integer', $display_type = 'range_integer', array $settings = []) {
  if (!$this->viewDisplay) {
    $this
      ->createViewDisplay();
  }
  $this->viewDisplay
    ->setComponent($this
    ->getFieldName($field_type), [
    'type' => $display_type,
    'settings' => $settings,
  ]);
  $this->viewDisplay
    ->save();
}