protected function TaxonomyPermissionsTestBase::setViewDisplay in Taxonomy Permissions 8
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 TaxonomyPermissionsTestBase::setViewDisplay()
- TaxonomyPermissionsTestBase::attachFields in src/
Tests/ TaxonomyPermissionsTestBase.php - Helper function to create and attach a field to a node.
File
- src/
Tests/ TaxonomyPermissionsTestBase.php, line 300
Class
- TaxonomyPermissionsTestBase
- General setup and helper function for testing taxonomy permissions module.
Namespace
Drupal\taxonomy_permissions\TestsCode
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();
}
}