1
0
mirror of https://github.com/flarum/core.git synced 2025-10-11 23:14:29 +02:00

Rework extension bootstrapping

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.
This commit is contained in:
Toby Zerner
2015-07-20 18:08:28 +09:30
parent 19fe138770
commit 6b7cf1b6bf
12 changed files with 130 additions and 59 deletions

View File

@@ -47,6 +47,13 @@ class ClientView implements Renderable
*/
protected $layout;
/**
* An array of JS modules to import before booting the app.
*
* @var array
*/
protected $bootstrappers = ['locale'];
/**
* An array of strings to append to the page's <head>.
*
@@ -156,6 +163,16 @@ class ClientView implements Renderable
$this->footStrings[] = $string;
}
/**
* Add a JavaScript module to be imported before the app is booted.
*
* @param string $string
*/
public function addBootstrapper($string)
{
$this->bootstrappers[] = $string;
}
/**
* Get the view's asset manager.
*
@@ -196,6 +213,7 @@ class ClientView implements Renderable
$view->head = implode("\n", $this->headStrings);
$view->foot = implode("\n", $this->footStrings);
$view->bootstrappers = $this->bootstrappers;
return $view->render();
}