public function EntityManager::getBundleSettings in Simple XML sitemap 4.x
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 EntityManager::getBundleSettings()
- EntityManager::bundleIsIndexed in src/
Manager/ EntityManager.php - Checks if an entity bundle (or a non-bundle entity type) is set to be indexed for any of the currently set variants.
- EntityManager::getEntityInstanceSettings in src/
Manager/ EntityManager.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…
- EntityManager::setBundleSettings in src/
Manager/ EntityManager.php - Sets settings for bundle or non-bundle entity types. This is done for the currently set variant. Note that this method takes only the first set variant into account. See todo.
- EntityManager::setEntityInstanceSettings in src/
Manager/ EntityManager.php - Overrides sitemap settings for a single entity for the currently set variants.
File
- src/
Manager/ EntityManager.php, line 236
Class
- EntityManager
- Class EntityManager
Namespace
Drupal\simple_sitemap\ManagerCode
public function getBundleSettings(?string $entity_type_id = NULL, ?string $bundle_name = NULL, bool $supplement_defaults = TRUE, bool $multiple_variants = FALSE) {
$bundle_name = $bundle_name ?? $entity_type_id;
$all_bundle_settings = [];
foreach ($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($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($bundle_settings[$type_id][$bundle]);
}
}
}
}
}
if ($multiple_variants) {
$all_bundle_settings[$variant] = $bundle_settings;
}
else {
return $bundle_settings;
}
}
return $all_bundle_settings;
}