mirror of
https://github.com/flarum/core.git
synced 2025-10-18 18:26:07 +02:00
Make the Request available to the Formatter\Rendering event (#1721)
This is important because extensions may wish to render post content differently depending on Request factors such as the actor. For example, an attachments extension might wish to hide attachments from guests. This solution is a bit of a hack-job for now, but soon when we refactor the API layer to use tobscure/json-api-server, and also refactor the Formatter layer, it can be revised.
This commit is contained in:
committed by
Franz Liedke
parent
9b68bbe44e
commit
0ab9facc4b
@@ -18,12 +18,12 @@ use Flarum\Post\Event\Posted;
|
||||
use Flarum\Post\Event\Restored;
|
||||
use Flarum\Post\Event\Revised;
|
||||
use Flarum\User\User;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* A standard comment in a discussion.
|
||||
*
|
||||
* @property string $parsed_content
|
||||
* @property string $content_html
|
||||
*/
|
||||
class CommentPost extends Post
|
||||
{
|
||||
@@ -166,11 +166,12 @@ class CommentPost extends Post
|
||||
/**
|
||||
* Get the content rendered as HTML.
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
* @return string
|
||||
*/
|
||||
public function getContentHtmlAttribute()
|
||||
public function formatContent(ServerRequestInterface $request)
|
||||
{
|
||||
return static::$formatter->render($this->attributes['content'], $this);
|
||||
return static::$formatter->render($this->attributes['content'], $this, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user