Skip to content

Commit

Permalink
Use eager loaded tag state + null handling
Browse files Browse the repository at this point in the history
Closes #72, ref #45 and #46.
Seems like the only issue with the original PR is that a null state (doesn't exist) wasn't handled, while the original code always returned a dummy state if it didn't exist in the DB.
The added '?? null' avoids warnings/notices regarding null->subscription (which depends on PHP version)
  • Loading branch information
dsevillamartin committed Jul 6, 2024
1 parent b76d70b commit f054a0c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/AddTagSubscriptionAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class AddTagSubscriptionAttribute
public function __invoke(TagSerializer $serializer, Tag $tag, array $attributes): array
{
/** @var TagState $state */
$state = $tag->stateFor($serializer->getActor());
$state = $tag->state;

$attributes['subscription'] = $state->subscription;
$attributes['subscription'] = $state->subscription ?? null;

return $attributes;
}
Expand Down

0 comments on commit f054a0c

Please sign in to comment.