public function RelationType::getBundles in Relation 8.2
Same name and namespace in other branches
- 8 src/Entity/RelationType.php \Drupal\relation\Entity\RelationType::getBundles()
Get valid entity/bundle pairs that can be associated with this type of Relation.
Parameters
NULL|string $direction: Bundle direction. Leave as NULL to get all.
Return value
array An array containing bundles as key/value pairs, keyed by entity type.
Overrides RelationTypeInterface::getBundles
File
- src/
Entity/ RelationType.php, line 191
Class
- RelationType
- Defines relation type entity.
Namespace
Drupal\relation\EntityCode
public function getBundles($direction = NULL) {
$pairs = array();
if ((!$direction || $direction == 'source') && is_array($this->source_bundles)) {
$pairs += $this->source_bundles;
}
if ((!$direction || $direction == 'target') && is_array($this->target_bundles)) {
$pairs += $this->target_bundles;
}
$bundles = array();
foreach ($pairs as $pair) {
list($entity_type_id, $bundle) = explode(':', $pair, 2);
$bundles[$entity_type_id][$bundle] = $bundle;
}
return $bundles;
}