Completed
Pull Request — master (#157)
by
unknown
01:50
created

TaxonomyTermDrupal8::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
namespace Drupal\Driver\Plugin\DriverEntity;
3
4
use Drupal\Driver\Plugin\DriverEntityPluginDrupal8Base;
5
6
/**
7
 * A driver field plugin used to test selecting an arbitrary plugin.
8
 *
9
 * @DriverEntity(
10
 *   id = "taxonomy_term8",
11
 *   version = 8,
12
 *   weight = -100,
13
 *   entityTypes = {
14
 *     "taxonomy_term",
15
 *   },
16
 * )
17
 */
18 View Code Duplication
class TaxonomyTermDrupal8 extends DriverEntityPluginDrupal8Base
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
21
  /**
22
   * The id of the attached term.
23
   *
24
   * @var integer;
25
   *
26
   * @deprecated Use id() instead.
27
   */
28
    public $tid;
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function load($entityId)
34
    {
35
        $entity = parent::load($entityId);
36
        $this->tid = is_null($this->entity) ? NULL : $this->id();
0 ignored issues
show
Deprecated Code introduced by
The property Drupal\Driver\Plugin\Dri...xonomyTermDrupal8::$tid has been deprecated with message: Use id() instead.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
37
        return $entity;
38
    }
39
40
  /**
41
   * {@inheritdoc}
42
   */
43
    public function save()
44
    {
45
        parent::save();
46
        $this->tid = $this->id();
0 ignored issues
show
Deprecated Code introduced by
The property Drupal\Driver\Plugin\Dri...xonomyTermDrupal8::$tid has been deprecated with message: Use id() instead.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
47
    }
48
49
  /**
50
   * {@inheritdoc}
51
   */
52
    public function getBundleKeyLabels()
53
    {
54
        // Previously we made 'vocabulary_machine_name' available as a more
55
        // human-friendly alternative to 'vid' for the bundle field identifier.
56
        // This is now unnecessary as the label 'vocabulary' is available
57
        // automatically, but it is supported here for backwards-compatibility.
58
        $bundleKeyLabels = parent::getBundleKeyLabels();
59
        $bundleKeyLabels[] = 'vocabulary_machine_name';
60
        return $bundleKeyLabels;
61
    }
62
}
63