<?php namespace Cit\Tracker\Listeners;
use Flarum\Event\ConfigureClientView;
use Illuminate\Contracts\Events\Dispatcher;
use Flarum\Settings\SettingsRepositoryInterface;
class AddFootPrintJs
{
/**
* @var SettingsRepositorys
*/
protected $settings;
public function __construct(SettingsRepositoryInterface $settings)
{
$this->settings = $settings;
}
public function subscribe(Dispatcher $events)
{
$events->listen(ConfigureClientView::class, [$this, 'addAssets']);
}
public function addAssets(ConfigureClientView $event)
{
if ($event->isForum()) {
$user_id =$view->getActor()->id;
$rawJs = file_get_contents(realpath(__DIR__ . '/../../assets/js/cittracker.js'));
$js = str_replace('%%USER_ID%%', $user_id, $rawJs);
$event->view->addFootString($js);
}
}
}
is it correct..?