Skip to content

Commit

Permalink
Reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed Aug 8, 2024
1 parent f7a2dd2 commit db8111d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Sitemaps/Custom/CustomSitemapUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public function loc(?string $loc = null): string|self
public function alternates(?array $alternates = null): array|self|null
{
return $this->fluentlyGetOrSet('alternates')
->getter(function ($alternates) {
return collect($alternates)->map(function ($alternate) {
$alternate['href'] = $this->absoluteUrl($alternate['href']);

return $alternate;
})->all();
})
->setter(function ($alternates) {
foreach ($alternates as $alternate) {
throw_unless(array_key_exists('href', $alternate), new \Exception("One of your alternate links is missing the 'href' attribute."));
Expand All @@ -39,13 +46,6 @@ public function alternates(?array $alternates = null): array|self|null

return $alternates;
})
->getter(function ($alternates) {
return collect($alternates)->map(function ($alternate) {
$alternate['href'] = $this->absoluteUrl($alternate['href']);

return $alternate;
})->all();
})
->args(func_get_args());
}

Expand Down

0 comments on commit db8111d

Please sign in to comment.