mirror of
https://github.com/flarum/core.git
synced 2025-10-10 14:34:30 +02:00
System JS modules don't execute when they're registered, so we need to import them explicitly. While we're at it, we may as well make the locale bootstrapper a module too.
58 lines
1.2 KiB
PHP
58 lines
1.2 KiB
PHP
<?php namespace Flarum\Events;
|
|
|
|
use Flarum\Support\ClientAction;
|
|
use Flarum\Support\ClientView;
|
|
use Flarum\Forum\Actions\ClientAction as ForumClientAction;
|
|
|
|
class BuildClientView
|
|
{
|
|
/**
|
|
* @var ClientAction
|
|
*/
|
|
public $action;
|
|
|
|
/**
|
|
* @var ClientView
|
|
*/
|
|
public $view;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
public $keys;
|
|
|
|
/**
|
|
* @param ClientAction $action
|
|
* @param ClientView $view
|
|
* @param array $keys
|
|
*/
|
|
public function __construct($action, $view, &$keys)
|
|
{
|
|
$this->action = $action;
|
|
$this->view = $view;
|
|
$this->keys = &$keys;
|
|
}
|
|
|
|
public function forumAssets($files)
|
|
{
|
|
if ($this->action instanceof ForumClientAction) {
|
|
$this->view->getAssets()->addFiles((array) $files);
|
|
}
|
|
}
|
|
|
|
public function forumBootstrapper($bootstrapper)
|
|
{
|
|
if ($this->action instanceof ForumClientAction) {
|
|
$this->view->addBootstrapper($bootstrapper);
|
|
}
|
|
}
|
|
|
|
public function forumTranslations(array $keys)
|
|
{
|
|
if ($this->action instanceof ForumClientAction) {
|
|
foreach ($keys as $key) {
|
|
$this->keys[] = $key;
|
|
}
|
|
}
|
|
}}
|