protected function PbfBaseTest::attachPbfUserFields in Permissions by field 8
Attach Pbf fields which reference Users.
Parameters
string $field_name: The field name created.
string $user_method: The user method which calculate access permissions.
2 calls to PbfBaseTest::attachPbfUserFields()
- PbfAccessByUserDirectTest::setUp in tests/
src/ Functional/ PbfAccessByUserDirectTest.php - Setup and create content whith Pbf field.
- PbfAccessByUserRefTest::setUp in tests/
src/ Functional/ PbfAccessByUserRefTest.php - Setup and create content whith Pbf field.
File
- tests/
src/ Functional/ PbfBaseTest.php, line 529
Class
- PbfBaseTest
- General setup and helper function for testing pbf module.
Namespace
Drupal\Tests\pbf\FunctionalCode
protected function attachPbfUserFields($field_name, $user_method = 'user') {
$handler_settings = array(
'target_bundles' => array(
'user' => 'user',
),
'auto_create' => FALSE,
);
// Add a pbf field to the article content type which reference term.
$this
->createPbfField('node', 'article', $field_name, 'Grant access to user', 'user', 'default', $handler_settings, -1, $user_method);
// Set the form display.
$settings = [
'match_operator' => 'CONTAINS',
'size' => 30,
'placeholder' => '',
];
$this
->setFormDisplay('node.article.default', 'node', 'article', '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);
if ($user_method == 'ref_user') {
// Add a pbf field to user entity which reference term.
$this
->createPbfField('user', 'user', $field_name, 'User related to user', 'user', 'default', $handler_settings, -1);
$this
->setFormDisplay('user.user.default', 'user', 'user', 'default', $field_name, 'pbf_widget', $settings);
$this
->setViewDisplay('user.user.default', 'user', 'user', 'default', $field_name, 'pbf_formatter_default', $settings);
}
}