Rasmus Vind
Well-known member
I have a system where people submit content and in order for said content to be approved, a moderator approves/rejects it and posts a review at the same time. Similar to XF but it has more states and more options directed at this type of content.
Now, I wanted to make an inline-moderation version of this moderation but I have no good way to get the content of the editor because I am not able to get the controller from here.
Take a look at my example below:
I am trying to get to the XF:Editor controller plugin by trying to get some global instance of a controller because at this stage, the controller we came from is not in scope.
So far, the best solution I can think of is to actually copy-paste the code from this plugin into my code but that seems dirty and a maintenance risk in case the editor changes in the future.
CC: @Mike, @Kier, @Chris D
Now, I wanted to make an inline-moderation version of this moderation but I have no good way to get the content of the editor because I am not able to get the controller from here.
Take a look at my example below:
PHP:
<?php
namespace VindIT\Repository\InlineMod\Bundle;
use XF\InlineMod\AbstractAction;
use XF\Mvc\Entity\Entity;
use XF\Mvc\Entity\AbstractCollection;
use XF\Http\Request;
class SetReviewState extends AbstractAction
{
// [...]
// This one displays an editor
public function renderForm(AbstractCollection $entities, \XF\Mvc\Controller $controller)
{
$viewParams = [
'threads' => $entities,
'total' => count($entities),
];
return $controller->view('VindIT\Repository:Public:InlineMod\Bundle\SetReviewState', 'ratory_moderate_bundle', $viewParams);
}
public function getFormOptions(AbstractCollection $entities, Request $request)
{
$app = $this->app();
// Spoiler: This does not work
$editorPlugin = $app->controller->plugin('XF:Editor')->fromInput('message');
return [
'state' => $request->filter('review_state', 'str'),
'replace_reviews' => $request->filter('replace_reviews', 'str'),
'send_alert' => $request->filter('send_alert', 'bool'),
'message' => $editorPlugin->fromInput('message'),
];
}
}
So far, the best solution I can think of is to actually copy-paste the code from this plugin into my code but that seems dirty and a maintenance risk in case the editor changes in the future.
CC: @Mike, @Kier, @Chris D