public function Simplesitemap::getBundleSettings in Simple XML sitemap 8.3
Same name and namespace in other branches
- 8.2 src/Simplesitemap.php \Drupal\simple_sitemap\Simplesitemap::getBundleSettings()
Gets settings for bundle or non-bundle entity types. This is done for the currently set variants.
Parameters
string|null $entity_type_id: Limit the result set to a specific entity type.
string|null $bundle_name: Limit the result set to a specific bundle name.
bool $supplement_defaults: Supplements the result set with default bundle settings.
bool $multiple_variants: If true, returns an array of results keyed by variant name, otherwise it returns the result set for the first variant only.
Return value
array|false Array of settings or array of settings keyed by variant name. False if entity type does not exist.
4 calls to Simplesitemap::getBundleSettings()
- Simplesitemap::bundleIsIndexed in src/
Simplesitemap.php - Checks if an entity bundle (or a non-bundle entity type) is set to be indexed for any of the currently set variants.
- Simplesitemap::getEntityInstanceSettings in src/
Simplesitemap.php - Gets sitemap settings for an entity instance which overrides bundle settings, or gets bundle settings, if they are not overridden. This is done for the currently set variant. Please note, this method takes only the first set variant into account. See…
- Simplesitemap::setBundleSettings in src/
Simplesitemap.php - Sets settings for bundle or non-bundle entity types. This is done for the currently set variant.
- Simplesitemap::setEntityInstanceSettings in src/
Simplesitemap.php - Overrides sitemap settings for a single entity for the currently set variants.
File
- src/
Simplesitemap.php, line 568
Class
- Simplesitemap
- Class Simplesitemap @package Drupal\simple_sitemap
Namespace
Drupal\simple_sitemapCode
public function getBundleSettings($entity_type_id = NULL, $bundle_name = NULL, $supplement_defaults = TRUE, $multiple_variants = FALSE) {
$bundle_name = NULL !== $bundle_name ? $bundle_name : $entity_type_id;
$all_bundle_settings = [];
foreach ($variants = $this
->getVariants(FALSE) as $variant) {
if (NULL !== $entity_type_id) {
$bundle_settings = $this->configFactory
->get("simple_sitemap.bundle_settings.{$variant}.{$entity_type_id}.{$bundle_name}")
->get();
if (empty($bundle_settings) && $supplement_defaults) {
self::supplementDefaultSettings('entity', $bundle_settings);
}
}
else {
$config_names = $this->configFactory
->listAll("simple_sitemap.bundle_settings.{$variant}.");
$bundle_settings = [];
foreach ($config_names as $config_name) {
$config_name_parts = explode('.', $config_name);
$bundle_settings[$config_name_parts[3]][$config_name_parts[4]] = $this->configFactory
->get($config_name)
->get();
}
// Supplement default bundle settings for all bundles not found in simple_sitemap.bundle_settings.*.* configuration.
if ($supplement_defaults) {
foreach ($this->entityHelper
->getSupportedEntityTypes() as $type_id => $type_definition) {
foreach ($this->entityHelper
->getBundleInfo($type_id) as $bundle => $bundle_definition) {
if (!isset($bundle_settings[$type_id][$bundle])) {
self::supplementDefaultSettings('entity', $bundle_settings[$type_id][$bundle]);
}
}
}
}
}
if ($multiple_variants) {
$all_bundle_settings[$variant] = $bundle_settings;
}
else {
return $bundle_settings;
}
}
return $all_bundle_settings;
}