entity_generic-8.x-3.x-dev/src/Generic/EntityTypedTrait.php
src/Generic/EntityTypedTrait.php
<?php
namespace Drupal\entity_generic\Generic;
/**
* Implements types functionality.
*/
trait EntityTypedTrait {
/**
* {@inheritdoc}
*/
public function getType() {
return $this->getEntityType()->hasKey('bundle') ? $this->bundle() : $this->getEntityTypeId();
}
/**
* {@inheritdoc}
*/
public function setType($type) {
$key = $this->getEntityType()->getKey('bundle');
// Set bundle only if entity has bundles.
if ($key) {
$this->set($key, $type);
$this->entityKeys[$key] = $type;
}
return $this;
}
}
