You are here

public function Entity::__construct in Like & Dislike 7

Parameters

stdclass $entity:

File

src/Model/Entity.php, line 21

Class

Entity
@file

Namespace

Drupal\like_and_dislike\Model

Code

public function __construct($entity) {
  if (isset($entity->nid)) {
    if (isset($entity->node_type)) {
      $this->entity_id = $entity->cid;
      $this->entity_type = 'comment';
      $this->bundle = $entity->node_type;
    }
    else {
      $this->entity_id = $entity->nid;
      $this->entity_type = 'node';
      $this->bundle = $entity->type;
    }
  }
}