Completed
Pull Request — 8.x-1.x (#123)
by
unknown
02:27
created

EntityLabel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 24
wmc 3
lcom 0
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A view() 0 3 1
A settingsForm() 0 3 1
A isApplicable() 0 3 1
1
<?php
2
3
/**
4
 * Contains \Drupal\entity_browser\Plugin\EntityBrowser\FieldWidgetDisplay\EntityLabel.
5
 */
6
7
namespace Drupal\entity_browser\Plugin\EntityBrowser\FieldWidgetDisplay;
8
9
use Drupal\Core\Entity\EntityInterface;
10
use Drupal\Core\Entity\EntityTypeInterface;
11
use Drupal\Core\Form\FormStateInterface;
12
use Drupal\Core\Plugin\PluginBase;
13
use Drupal\entity_browser\FieldWidgetDisplayInterface;
14
15
/**
16
 * Displays a label of the entity.
17
 *
18
 * @EntityBrowserFieldWidgetDisplay(
19
 *   id = "label",
20
 *   label = @Translation("Entity label"),
21
 *   description = @Translation("Displays entity with a label.")
22
 * )
23
 */
24
class EntityLabel extends PluginBase implements FieldWidgetDisplayInterface {
25
26
  /**
27
   * {@inheritdoc}
28
   */
29
  public function view(EntityInterface $entity) {
30
    return $entity->label();
31
  }
32
33
  /**
34
   * {@inheritdoc}
35
   */
36
  public function settingsForm(array $form, FormStateInterface $form_state) {
37
    return [];
38
  }
39
40
  /**
41
   * {@inheritdoc}
42
   */
43
  public function isApplicable(EntityTypeInterface $entity_type) {
44
    return TRUE;
45
  }
46
47
}
48