You are here

protected function PbfBaseTest::attachPbfRoleFields in Permissions by field 8

Helper function to create and attach a Pbf Role field.

Parameters

string $field_name: The field name to create and attach.

1 call to PbfBaseTest::attachPbfRoleFields()
PbfAccessByRoleTest::setUp in tests/src/Functional/PbfAccessByRoleTest.php
Setup and create content whith Pbf field.

File

tests/src/Functional/PbfBaseTest.php, line 568

Class

PbfBaseTest
General setup and helper function for testing pbf module.

Namespace

Drupal\Tests\pbf\Functional

Code

protected function attachPbfRoleFields($field_name) {
  $handler_settings = array(
    'target_bundles' => NULL,
    'auto_create' => FALSE,
  );

  // Add a pbf field to the article content type which reference term.
  $this
    ->createPbfField('node', 'article', $field_name, 'Grant access to role', 'user_role', 'default', $handler_settings, -1);

  // 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' => FALSE,
  ];
  $this
    ->setViewDisplay('node.article.default', 'node', 'article', 'default', $field_name, 'pbf_formatter_default', $settings);
}