public function Simplesitemap::getCustomLinks in Simple XML sitemap 8.3
Same name and namespace in other branches
- 8.2 src/Simplesitemap.php \Drupal\simple_sitemap\Simplesitemap::getCustomLinks()
Gets custom link settings for the currently set variants.
Parameters
string|null $path: Limits the result set by an internal path.
bool $supplement_defaults: Supplements the result set with default custom link 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|mixed|null
2 calls to Simplesitemap::getCustomLinks()
- Simplesitemap::addCustomLink in src/
Simplesitemap.php - Stores a custom path along with its settings to configuration for the currently set variants.
- Simplesitemap::removeCustomLinks in src/
Simplesitemap.php - Removes custom links from currently set variants.
File
- src/
Simplesitemap.php, line 916
Class
- Simplesitemap
- Class Simplesitemap @package Drupal\simple_sitemap
Namespace
Drupal\simple_sitemapCode
public function getCustomLinks($path = NULL, $supplement_defaults = TRUE, $multiple_variants = FALSE) {
$all_custom_links = [];
foreach ($variants = $this
->getVariants(FALSE) as $variant) {
$custom_links = $this->configFactory
->get("simple_sitemap.custom_links.{$variant}")
->get('links');
$custom_links = !empty($custom_links) ? $custom_links : [];
if (!empty($custom_links) && $path !== NULL) {
foreach ($custom_links as $key => $link) {
if ($link['path'] !== $path) {
unset($custom_links[$key]);
}
}
}
if (!empty($custom_links) && $supplement_defaults) {
foreach ($custom_links as $i => $link_settings) {
self::supplementDefaultSettings('custom', $link_settings);
$custom_links[$i] = $link_settings;
}
}
$custom_links = $path !== NULL && !empty($custom_links) ? array_values($custom_links)[0] : array_values($custom_links);
if (!empty($custom_links)) {
if ($multiple_variants) {
$all_custom_links[$variant] = $custom_links;
}
else {
return $custom_links;
}
}
}
return $all_custom_links;
}