mirror of
https://github.com/flarum/framework.git
synced 2025-04-28 23:54:03 +08:00
fix: extensions not being able to use the renderer without context (#3382)
This commit is contained in:
parent
c944fd0029
commit
b0fa795cc9
@ -45,7 +45,7 @@ class FormatUserMentions
|
|||||||
public function __invoke(Renderer $renderer, $context, string $xml)
|
public function __invoke(Renderer $renderer, $context, string $xml)
|
||||||
{
|
{
|
||||||
return Utils::replaceAttributes($xml, 'USERMENTION', function ($attributes) use ($context) {
|
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'])
|
? $context->mentionsUsers->find($attributes['id'])
|
||||||
: User::find($attributes['id']);
|
: User::find($attributes['id']);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class UnparseUserMentions
|
|||||||
protected function updateUserMentionTags($context, string $xml): string
|
protected function updateUserMentionTags($context, string $xml): string
|
||||||
{
|
{
|
||||||
return Utils::replaceAttributes($xml, 'USERMENTION', function ($attributes) use ($context) {
|
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'])
|
? $context->mentionsUsers->find($attributes['id'])
|
||||||
: User::find($attributes['id']);
|
: User::find($attributes['id']);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user