protected function CountryAwareInOperatorBase::getBundles in Address 8
Gets the bundles for the current entity field.
If the view has a non-exposed bundle filter, the bundles are taken from there. Otherwise, the field's bundles are used.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The current entity type.
string $field_name: The current field name.
Return value
string[] The bundles.
1 call to CountryAwareInOperatorBase::getBundles()
- CountryAwareInOperatorBase::getAvailableCountries in src/
Plugin/ views/ filter/ CountryAwareInOperatorBase.php - Gets the list of available countries for the current entity field.
File
- src/
Plugin/ views/ filter/ CountryAwareInOperatorBase.php, line 167
Class
- CountryAwareInOperatorBase
- Abstract base class for country-aware InOperator views filters.
Namespace
Drupal\address\Plugin\views\filterCode
protected function getBundles(EntityTypeInterface $entity_type, $field_name) {
$bundles = [];
$bundle_key = $entity_type
->getKey('bundle');
if ($bundle_key && isset($this->view->filter[$bundle_key])) {
$filter = $this->view->filter[$bundle_key];
if (!$filter
->isExposed() && !empty($filter->value)) {
// 'all' is added by Views and isn't a bundle.
$bundles = array_diff($filter->value, [
'all',
]);
}
}
// Fallback to the list of bundles the field is attached to.
if (empty($bundles)) {
$map = $this->entityFieldManager
->getFieldMap();
$bundles = $map[$entity_type
->id()][$field_name]['bundles'];
}
return $bundles;
}