You are here

function EntityBase::GetBundle in Realistic Dummy Content 8

Get the bundle of the entity being manipulated.

All entities must have a type and a bundle. The type can be node, user, etc. and the bundle can be article, page. In case of a user, there must be a bundle even if there is only one: it is called user, like the entity type.

Return value

The bundle, for example "article" or "user". Is a bundle is not readily available, return the entity type.

File

api/src/manipulators/EntityBase.php, line 95
Define autoload class.

Class

EntityBase
Generic entity manipulator.

Namespace

Drupal\realistic_dummy_content_api\manipulators

Code

function GetBundle() {
  $entity = $this
    ->GetEntity();
  $type = $entity
    ->getType();
  if ($type) {
    $return = $type;
  }
  else {
    $return = $this
      ->GetType();
  }
  if (!is_string($return)) {
    throw new Exception('EntityBase::GetBundle() internal error, not returning a string');
  }
  return $return;
}