mirror of
https://github.com/flarum/core.git
synced 2025-08-12 03:14:33 +02:00
Frontend refactor (#1471)
Refactor Frontend + Asset code - Use Laravel's Filesystem component for asset IO, meaning theoretically assets should be storable on S3 etc. - More reliable checking for asset recompilation when debug mode is on, so you don't have to constantly delete the compiled assets to force a recompile. Should also fix issues with locale JS files being recompiled with the same name and cached. - Remove JavaScript minification, because it will be done by Webpack (exception is for the TextFormatter JS). - Add support for JS sourcemaps. - Separate frontend view and assets completely. This is an important distinction because frontend assets are compiled independent of a request, whereas putting together a view depends on a request. - Bind frontend view/asset factory instances to the container (in service providers) rather than subclassing. Asset and content populators can be added to these factories – these are simply objects that populate the asset compilers or the view with information. - Add RouteHandlerFactory functions that make it easy to hook up a frontend controller with a frontend instance ± some content. - Remove the need for "nojs" - Fix cache:clear command - Recompile assets when settings/enabled extensions change
This commit is contained in:
@@ -14,26 +14,15 @@ namespace Flarum\Settings\Event;
|
||||
class Saved
|
||||
{
|
||||
/**
|
||||
* The setting key that was set.
|
||||
*
|
||||
* @var string
|
||||
* @var array
|
||||
*/
|
||||
public $key;
|
||||
public $settings;
|
||||
|
||||
/**
|
||||
* The setting value that was set.
|
||||
*
|
||||
* @var string
|
||||
* @param array $settings
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @param string $key The setting key that was set.
|
||||
* @param string $value The setting value that was set.
|
||||
*/
|
||||
public function __construct($key, $value)
|
||||
public function __construct(array $settings)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->value = $value;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
}
|
||||
|
28
src/Settings/Event/Saving.php
Normal file
28
src/Settings/Event/Saving.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Settings\Event;
|
||||
|
||||
class Saving
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $settings;
|
||||
|
||||
/**
|
||||
* @param array $settings
|
||||
*/
|
||||
public function __construct(array &$settings)
|
||||
{
|
||||
$this->settings = &$settings;
|
||||
}
|
||||
}
|
61
src/Settings/OverrideSettingsRepository.php
Normal file
61
src/Settings/OverrideSettingsRepository.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Settings;
|
||||
|
||||
/**
|
||||
* A settings repository decorator that allows overriding certain values.
|
||||
*
|
||||
* The `OverrideSettingsRepository` class decorates another
|
||||
* `SettingsRepositoryInterface` instance but allows certain settings to be
|
||||
* overridden with predefined values. It does not affect writing methods.
|
||||
*
|
||||
* Within Flarum, this can be used to test out new setting values in a system
|
||||
* before they are committed to the database.
|
||||
*
|
||||
* @see \Flarum\Forum\RecompileFrontendAssets For an example usage.
|
||||
*/
|
||||
class OverrideSettingsRepository implements SettingsRepositoryInterface
|
||||
{
|
||||
protected $inner;
|
||||
|
||||
protected $overrides = [];
|
||||
|
||||
public function __construct(SettingsRepositoryInterface $inner, array $overrides)
|
||||
{
|
||||
$this->inner = $inner;
|
||||
$this->overrides = $overrides;
|
||||
}
|
||||
|
||||
public function all()
|
||||
{
|
||||
return array_merge($this->inner->all(), $this->overrides);
|
||||
}
|
||||
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
if (array_key_exists($key, $this->overrides)) {
|
||||
return $this->overrides[$key];
|
||||
}
|
||||
|
||||
return array_get($this->all(), $key, $default);
|
||||
}
|
||||
|
||||
public function set($key, $value)
|
||||
{
|
||||
$this->inner->set($key, $value);
|
||||
}
|
||||
|
||||
public function delete($key)
|
||||
{
|
||||
$this->inner->delete($key);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user