protected function PbfBaseTest::attachPbfSynchronizedFields in Permissions by field 8
Helper function to create and attach a Pbf Node field synchronized.
Parameters
string $field_name: The field name to create and attach on article and user.
string $group_field_name: The field name to create and attach on group.
array $widget_settings: The widget form settings.
1 call to PbfBaseTest::attachPbfSynchronizedFields()
- PbfAccessWithSynchronizationTest::setUp in tests/
src/ Functional/ PbfAccessWithSynchronizationTest.php - Setup and create content with Pbf field.
File
- tests/
src/ Functional/ PbfBaseTest.php, line 442
Class
- PbfBaseTest
- General setup and helper function for testing pbf module.
Namespace
Drupal\Tests\pbf\FunctionalCode
protected function attachPbfSynchronizedFields($field_name, $group_field_name, $widget_settings = []) {
// Add a pbf field to the article content type which reference group.
$handler_settings = array(
'target_bundles' => array(
'group' => 'group',
),
'auto_create' => FALSE,
);
$this
->createPbfField('node', 'article', $field_name, 'Content of group', 'node', 'default', $handler_settings, -1);
// Add a pbf field to user entity which reference group.
$this
->createPbfField('user', 'user', $field_name, 'Member of group', 'node', 'default', $handler_settings, -1);
// Add a pbf field to group content type which reference user.
$handler_settings = array(
'target_bundles' => array(
'user' => 'user',
),
'auto_create' => FALSE,
);
$this
->createPbfField('node', 'group', $group_field_name, 'Group members', 'user', 'default', $handler_settings, -1);
// Set the form display.
$settings = $widget_settings + [
'match_operator' => 'CONTAINS',
'match_limit' => 10,
'size' => 30,
'placeholder' => '',
];
$this
->setFormDisplay('node.article.default', 'node', 'article', 'default', $field_name, 'pbf_widget', $settings);
$this
->setFormDisplay('node.group.default', 'node', 'group', 'default', $group_field_name, 'pbf_widget', $settings);
$this
->setFormDisplay('user.user.default', 'user', 'user', 'default', $field_name, 'pbf_widget', $settings);
// Set the view display.
$settings = [
'link' => TRUE,
];
$this
->setViewDisplay('node.article.default', 'node', 'article', 'default', $field_name, 'pbf_formatter_default', $settings);
$this
->setViewDisplay('node.group.default', 'node', 'group', 'default', $group_field_name, 'pbf_formatter_default', $settings);
$this
->setViewDisplay('user.user.default', 'user', 'user', 'default', $field_name, 'pbf_formatter_default', $settings);
}