Skip to content

Commit

Permalink
fix: extensions not being able to use the renderer without context (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland authored Apr 7, 2022
1 parent c944fd0 commit b0fa795
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion extensions/mentions/src/Formatter/FormatUserMentions.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(SlugManager $slugManager, TranslatorInterface $trans
public function __invoke(Renderer $renderer, $context, string $xml)
{
return Utils::replaceAttributes($xml, 'USERMENTION', function ($attributes) use ($context) {
$user = (isset($context->getRelations()['mentionsUsers']) || $context instanceof Post)
$user = (($context && isset($context->getRelations()['mentionsUsers'])) || $context instanceof Post)
? $context->mentionsUsers->find($attributes['id'])
: User::find($attributes['id']);

Expand Down
2 changes: 1 addition & 1 deletion extensions/mentions/src/Formatter/UnparseUserMentions.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __invoke($context, string $xml)
protected function updateUserMentionTags($context, string $xml): string
{
return Utils::replaceAttributes($xml, 'USERMENTION', function ($attributes) use ($context) {
$user = (isset($context->getRelations()['mentionsUsers']) || $context instanceof Post)
$user = (($context && isset($context->getRelations()['mentionsUsers'])) || $context instanceof Post)
? $context->mentionsUsers->find($attributes['id'])
: User::find($attributes['id']);

Expand Down

0 comments on commit b0fa795

Please sign in to comment.