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

NodeDrupal8::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 = "node8",
11
 *   version = 8,
12
 *   weight = -100,
13
 *   entityTypes = {
14
 *     "node",
15
 *   },
16
 * )
17
 */
18 View Code Duplication
class NodeDrupal8 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 node.
23
   *
24
   * @var integer;
25
   *
26
   * @deprecated Use id() instead.
27
   */
28
    public $nid;
29
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function load($entityId)
35
    {
36
        $entity = parent::load($entityId);
37
        $this->nid = is_null($this->entity) ? NULL : $this->id();
0 ignored issues
show
Deprecated Code introduced by
The property Drupal\Driver\Plugin\Dri...ntity\NodeDrupal8::$nid 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...
38
        return $entity;
39
    }
40
41
  /**
42
   * {@inheritdoc}
43
   */
44
    public function save()
45
    {
46
        parent::save();
47
        $this->nid = $this->id();
0 ignored issues
show
Deprecated Code introduced by
The property Drupal\Driver\Plugin\Dri...ntity\NodeDrupal8::$nid 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...
48
    }
49
50
  /**
51
   * {@inheritdoc}
52
   */
53
    public function set($identifier, $field)
54
    {
55
        if ($identifier === 'author') {
56
            $identifier = 'uid';
57
        }
58
        parent::set($identifier, $field);
59
    }
60
}
61