protected function BlazyCreationTestTrait::getFormatterInstance in Blazy 8
Same name and namespace in other branches
- 8.2 tests/src/Traits/BlazyCreationTestTrait.php \Drupal\Tests\blazy\Traits\BlazyCreationTestTrait::getFormatterInstance()
Returns the field formatter instance.
Parameters
string $plugin_id: Formatter plugin ID.
string $field_name: Formatted field name.
Return value
\Drupal\Core\Field\FormatterInterface|null The field formatter instance.
2 calls to BlazyCreationTestTrait::getFormatterInstance()
- BlazyEntityReferenceFormatterTest::setUp in tests/
src/ Kernel/ BlazyEntityReferenceFormatterTest.php - BlazyFormatterTest::setUp in tests/
src/ Kernel/ BlazyFormatterTest.php - Set the default field storage backend for fields created during tests.
File
- tests/
src/ Traits/ BlazyCreationTestTrait.php, line 137
Class
- BlazyCreationTestTrait
- A Trait common for Blazy tests.
Namespace
Drupal\Tests\blazy\TraitsCode
protected function getFormatterInstance($plugin_id = '', $field_name = '') {
$plugin_id = empty($plugin_id) ? $this->testPluginId : $plugin_id;
$field_name = empty($field_name) ? $this->testFieldName : $field_name;
$settings = $this
->getFormatterSettings() + $this->formatterPluginManager
->getDefaultSettings($plugin_id);
if (!$this
->getBlazyFieldDefinition($field_name)) {
return NULL;
}
$options = [
'field_definition' => $this
->getBlazyFieldDefinition($field_name),
'configuration' => [
'type' => $plugin_id,
'settings' => $settings,
],
'view_mode' => 'default',
];
return $this->formatterPluginManager
->getInstance($options);
}