Customize your forum's appearance by adding your own LESS/CSS code to be applied on top of Flarum's default styles. Read the documentation for more information.
Customize your forum's appearance by adding your own LESS/CSS code to be applied on top of Flarum's default styles. Read the documentation for more information.
diff --git a/framework/core/src/Admin/Actions/ClientAction.php b/framework/core/src/Admin/Actions/ClientAction.php
index fceed15bb..a30a35ead 100644
--- a/framework/core/src/Admin/Actions/ClientAction.php
+++ b/framework/core/src/Admin/Actions/ClientAction.php
@@ -18,7 +18,6 @@ use Flarum\Api\Client;
use Flarum\Core\Settings\SettingsRepository;
use Flarum\Locale\LocaleManager;
use Flarum\Events\UnserializeConfig;
-use Flarum\Events\BuildAdminClientView;
class ClientAction extends BaseClientAction
{
@@ -42,14 +41,6 @@ class ClientAction extends BaseClientAction
$this->layout = __DIR__.'/../../../views/admin.blade.php';
}
- /**
- * {@inheritdoc}
- */
- protected function fireEvent(ClientView $view, array &$keys)
- {
- event(new BuildAdminClientView($this, $view, $keys));
- }
-
/**
* {@inheritdoc}
*/
diff --git a/framework/core/src/Events/BuildAdminClientView.php b/framework/core/src/Events/BuildAdminClientView.php
deleted file mode 100644
index 6e641d21c..000000000
--- a/framework/core/src/Events/BuildAdminClientView.php
+++ /dev/null
@@ -1,34 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Flarum\Events;
-
-use Flarum\Support\ClientView;
-use Flarum\Admin\Actions\ClientAction;
-
-class BuildAdminClientView extends BuildClientView
-{
- /**
- * @var ClientAction
- */
- public $action;
-
- /**
- * @param ClientAction $action
- * @param ClientView $view
- * @param array $keys
- */
- public function __construct(ClientAction $action, ClientView $view, array &$keys)
- {
- $this->action = $action;
- $this->view = $view;
- $this->keys = &$keys;
- }
-}
diff --git a/framework/core/src/Events/BuildClientView.php b/framework/core/src/Events/BuildClientView.php
index e8ea0bab2..c44bf7356 100644
--- a/framework/core/src/Events/BuildClientView.php
+++ b/framework/core/src/Events/BuildClientView.php
@@ -12,8 +12,10 @@ namespace Flarum\Events;
use Flarum\Support\ClientAction;
use Flarum\Support\ClientView;
+use Flarum\Admin\Actions\ClientAction as AdminClientAction;
+use Flarum\Forum\Actions\ClientAction as ForumClientAction;
-abstract class BuildClientView
+class BuildClientView
{
/**
* @var ClientAction
@@ -30,17 +32,39 @@ abstract class BuildClientView
*/
public $keys;
- public function assets($files)
+ /**
+ * @param ClientAction $action
+ * @param ClientView $view
+ * @param array $keys
+ */
+ public function __construct(ClientAction $action, ClientView $view, array &$keys)
+ {
+ $this->action = $action;
+ $this->view = $view;
+ $this->keys = &$keys;
+ }
+
+ public function isForum()
+ {
+ return $this->action instanceof ForumClientAction;
+ }
+
+ public function isAdmin()
+ {
+ return $this->action instanceof AdminClientAction;
+ }
+
+ public function addAssets($files)
{
$this->view->getAssets()->addFiles((array) $files);
}
- public function bootstrapper($bootstrapper)
+ public function addBootstrapper($bootstrapper)
{
$this->view->addBootstrapper($bootstrapper);
}
- public function translations(array $keys)
+ public function addTranslations(array $keys)
{
foreach ($keys as $key) {
$this->keys[] = $key;
diff --git a/framework/core/src/Events/BuildForumClientView.php b/framework/core/src/Events/BuildForumClientView.php
deleted file mode 100644
index e8ae0f7a1..000000000
--- a/framework/core/src/Events/BuildForumClientView.php
+++ /dev/null
@@ -1,34 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Flarum\Events;
-
-use Flarum\Support\ClientView;
-use Flarum\Forum\Actions\ClientAction;
-
-class BuildForumClientView extends BuildClientView
-{
- /**
- * @var ClientAction
- */
- public $action;
-
- /**
- * @param ClientAction $action
- * @param ClientView $view
- * @param array $keys
- */
- public function __construct(ClientAction $action, ClientView $view, array &$keys)
- {
- $this->action = $action;
- $this->view = $view;
- $this->keys = &$keys;
- }
-}
diff --git a/framework/core/src/Forum/Actions/ClientAction.php b/framework/core/src/Forum/Actions/ClientAction.php
index f2963561d..03fe5a8fb 100644
--- a/framework/core/src/Forum/Actions/ClientAction.php
+++ b/framework/core/src/Forum/Actions/ClientAction.php
@@ -15,7 +15,6 @@ use Flarum\Support\ClientView;
use Flarum\Api\Client;
use Flarum\Core\Settings\SettingsRepository;
use Flarum\Locale\LocaleManager;
-use Flarum\Events\BuildForumClientView;
class ClientAction extends BaseClientAction
{
@@ -39,14 +38,6 @@ class ClientAction extends BaseClientAction
$this->layout = __DIR__.'/../../../views/forum.blade.php';
}
- /**
- * {@inheritdoc}
- */
- protected function fireEvent(ClientView $view, array &$keys)
- {
- event(new BuildForumClientView($this, $view, $keys));
- }
-
/**
* @inheritdoc
*/
diff --git a/framework/core/src/Support/ClientAction.php b/framework/core/src/Support/ClientAction.php
index 60d447bc5..33d201c2a 100644
--- a/framework/core/src/Support/ClientAction.php
+++ b/framework/core/src/Support/ClientAction.php
@@ -19,6 +19,7 @@ use Flarum\Core\Settings\SettingsRepository;
use Flarum\Core\Users\User;
use Flarum\Locale\JsCompiler as LocaleJsCompiler;
use Flarum\Locale\LocaleManager;
+use Flarum\Events\BuildClientView;
use Psr\Http\Message\ServerRequestInterface as Request;
/**
@@ -121,7 +122,7 @@ abstract class ClientAction extends HtmlAction
// compile only the ones we need.
$keys = $this->translationKeys;
- $this->fireEvent($view, $keys);
+ event(new BuildClientView($this, $view, $keys));
if ($localeCompiler) {
$translations = $this->locales->getTranslations($locale);
@@ -134,13 +135,6 @@ abstract class ClientAction extends HtmlAction
return $view;
}
- /**
- * @param ClientView $view
- * @param array &$keys
- * @return void
- */
- abstract protected function fireEvent(ClientView $view, array &$keys);
-
/**
* Flush the client's assets so that they will be regenerated from scratch
* on the next render.