luceos Here is it on GitHub: https://github.com/MrPowerGamerBR/FlarumWhateverTest (Ignore the "FormatConfigMentions.php" on the directory root, I made that before I knew the files should be used on the /src/ directory)
EDIT: The bootstrap.php "subscribe" is commented because, if I didn't do that, I couldn't get to the admin panel, of course I was uncommenting when I was testing it.
JoshyPHP I'm not 100% expert in PHP, but I know how to make MySQL queries via PHP, so that is something? right? :/
Anyway, actually the text1 and the text2 are a bit "hard-coded", the text1 and the text2 will be used on a SQL Query (using PDO + bind, because of SQL Injection), if the query returns more than 1 row, then the file will be get.
EDIT: ooooooh, I get it, when a package is installed via composer, it is added to the main Flarum composer.json file.
EDIT 2: Now I could activate it without showing a error! Now progress is being made!
EDIT 3: It seems it is not doing anything at all... I tried using this code to test:
public function configure(ConfigureFormatter $event)
{
$configurator = $event->configurator;
$configurator->Preg->replace('/_(.*?)_/', '<em>$1</em>');
$configurator->Preg->replace('/%(.*?)%/', '<s>$1</s>');
}
However when writing %hi%, nothing happens.
The event is registered on the subscribe function:
public function subscribe(Dispatcher $events)
{
$events->listen(ConfigureFormatter::class, [$this, 'configure']);
$events->listen(ConfigureFormatterRenderer::class, [$this, 'render']);
}
I also tried the code @JoshyPHP shared, however it didn't work (No errors, just... nothing changed)
The event is registered, because if I add a echo in the subscribe function, it shows the text on the top of the page.
This is the bootstrap.php:
use MrPowerGamerBR\ConfigMarker\Listener;
use Illuminate\Contracts\Events\Dispatcher;
error_reporting(-1);
ini_set('display_errors', 'On');
return function (Dispatcher $events) {
$events->subscribe(Listener\FormatConfig::class);
};
This is the FormatConfig file:
namespace MrPowerGamerBR\ConfigMarker\Listener;
use Flarum\Core\Post\CommentPost;
use Flarum\Event\ConfigureFormatter;
use Flarum\Event\ConfigureFormatterRenderer;
use Illuminate\Contracts\Events\Dispatcher;
class FormatConfig
{
/**
* @param Dispatcher $events
*/
public function subscribe(Dispatcher $events)
{
$events->listen(ConfigureFormatter::class, [$this, 'configure']);
$events->listen(ConfigureFormatterRenderer::class, [$this, 'render']);
}
/**
* @param ConfigureFormatter $event
*/
public function configure(ConfigureFormatter $event)
{
$configurator = $event->configurator;
$configurator->Preg->replace('/_(.*?)_/', '<em>$1</em>');
$configurator->Preg->replace('/%(.*?)/', '<s>$1</s>');
}
/**
* @param ConfigureFormatterRenderer $event
*/
public function render(ConfigureFormatterRenderer $event)
{
}
}