public static function Video::mockInstance in Video Embed Field 8.2
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldFormatter/Video.php \Drupal\video_embed_field\Plugin\Field\FieldFormatter\Video::mockInstance()
Get an instance of the Video field formatter plugin.
This is useful because there is a lot of overlap to the configuration and display of a video in a WYSIWYG and configuring a field formatter. We get an instance of the plugin with our own WYSIWYG settings shimmed in, as well as a fake field_definition because one in this context doesn't exist. This allows us to reuse aspects such as the form and settings summary for the WYSIWYG integration.
Parameters
array $settings: The settings to pass to the plugin.
Return value
static The formatter plugin.
File
- src/
Plugin/ Field/ FieldFormatter/ Video.php, line 208
Class
- Video
- Plugin implementation of the video field formatter.
Namespace
Drupal\video_embed_field\Plugin\Field\FieldFormatterCode
public static function mockInstance($settings) {
return \Drupal::service('plugin.manager.field.formatter')
->createInstance('video_embed_field_video', [
'settings' => !empty($settings) ? $settings : [],
'third_party_settings' => [],
'field_definition' => new FieldConfig([
'field_name' => 'mock',
'entity_type' => 'mock',
'bundle' => 'mock',
]),
'label' => '',
'view_mode' => '',
]);
}