protected function LinkClassWidgetTest::setViewDisplay in Link class 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/LinkClassWidgetTest.php \Drupal\Tests\link_class\Functional\LinkClassWidgetTest::setViewDisplay()
Set the widget for a component in a View display.
Parameters
string $form_display_id: The form display id.
string $entity_type: The entity type name.
string $bundle: The bundle name.
string $field_name: The field name to set.
string $formatter_id: The formatter id to set.
array $settings: The settings of widget.
string $mode: The mode name.
1 call to LinkClassWidgetTest::setViewDisplay()
- LinkClassWidgetTest::testLinkClassWidget in tests/
src/ Functional/ LinkClassWidgetTest.php - Tests link class widget.
File
- tests/
src/ Functional/ LinkClassWidgetTest.php, line 288
Class
- LinkClassWidgetTest
- Tests link_class field widgets.
Namespace
Drupal\Tests\link_class\FunctionalCode
protected function setViewDisplay($form_display_id, $entity_type, $bundle, $field_name, $formatter_id, array $settings, $mode = 'default') {
// Set article's view display.
$this->viewDisplay = EntityViewDisplay::load($form_display_id);
if (!$this->viewDisplay) {
EntityViewDisplay::create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $mode,
'status' => TRUE,
])
->save();
$this->viewDisplay = EntityViewDisplay::load($form_display_id);
}
if ($this->viewDisplay instanceof EntityViewDisplayInterface) {
$this->viewDisplay
->setComponent($field_name, [
'type' => $formatter_id,
'settings' => $settings,
])
->save();
}
}