function EntityDataDefinition::setBundles

Sets the array of possible entity bundles.

Parameters

array|null $bundles: The array of possible bundles, or NULL for any.

Return value

$this

Overrides EntityDataDefinitionInterface::setBundles

File

core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php, line 141

Class

EntityDataDefinition
A typed data definition class for describing entities.

Namespace

Drupal\Core\Entity\TypedData

Code

public function setBundles(array $bundles = NULL) {
  if (isset($bundles)) {
    $this->addConstraint('Bundle', $bundles);
  }
  else {
    // Remove the constraint.
    unset($this->definition['constraints']['Bundle']);
  }
  return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.