Code Duplication    Length = 21-22 lines in 2 locations

src/EntityEmbedDisplay/FieldFormatterEntityEmbedDisplayBase.php 1 location

@@ 187-207 (lines=21) @@
184
   * @return \Drupal\Core\Field\FormatterInterface
185
   *   The formatter object.
186
   */
187
  public function getFieldFormatter() {
188
    if (!isset($this->fieldFormatter)) {
189
      $display = array(
190
        'type' => $this->getFieldFormatterId(),
191
        'settings' => $this->getConfiguration(),
192
        'label' => 'hidden',
193
      );
194
195
      // Create the formatter plugin. Will use the default formatter for that
196
      // field type if none is passed.
197
      $this->fieldFormatter = $this->formatterPluginManager->getInstance(
198
        array(
199
          'field_definition' => $this->getFieldDefinition(),
200
          'view_mode' => '_entity_embed',
201
          'configuration' => $display,
202
        )
203
      );
204
    }
205
206
    return $this->fieldFormatter;
207
  }
208
209
  /**
210
   * Creates a new faux-field definition.

src/Plugin/entity_embed/EntityEmbedDisplay/ViewModeFieldFormatter.php 1 location

@@ 24-45 (lines=22) @@
21
  /**
22
   * {@inheritdoc}
23
   */
24
  public function getFieldFormatter() {
25
    if (!isset($this->fieldFormatter)) {
26
      $display = [
27
        'type' => $this->getFieldFormatterId(),
28
        'settings' => [
29
          'view_mode' => $this->getPluginDefinition()['view_mode'],
30
        ],
31
        'label' => 'hidden',
32
      ];
33
34
      // Create the formatter plugin. Will use the default formatter for that
35
      // field type if none is passed.
36
      $this->fieldFormatter = $this->formatterPluginManager->getInstance(
37
        [
38
          'field_definition' => $this->getFieldDefinition(),
39
          'view_mode' => '_entity_embed',
40
          'configuration' => $display,
41
        ]
42
      );
43
    }
44
    return $this->fieldFormatter;
45
  }
46
47
  /**
48
   * {@inheritdoc}