Fixes#630
This allows global variables populated by the View::share('name', 'value') method to be used in Twig templates. The values will only be populated if they have not been specified as a global previously, to prevent overriding system globals such as this.page. It will also allow the pages themselves to still override the values if need be.
This persists the user's selection of sort method, sort direction, and view mode to their user preferences so that they retain their view preferences across sessions. The selections are keyed by the widget's alias, which effectively out of the box means that the main mediamanager instance and most if not all mediafinder popup widgets will have separate settings for this.
Implemented from user feedback complaining about the minor annoyance having to switch to sorting by the Last Modified Desc every time they opened the media manager.
Related: octobercms/october#3208. This issue surfaces when deployment tools attempt to run various commands not already protected (i.e. vapor:health-check) before running any migrations, which causes issues if plugins attempt to access the database during their registration or booting process.
In theory we could also apply this logic to HTTP requests, however it is generally easier to see and handle the reported exception of the table being missing in an HTTP context, so it's acceptable to limit this protection to the CLI.
As a reminder, plugins making use of the $elevated permissions are responsible for defensive measures to reliably operate in potentially unstable states of the application.
Related: octobercms/october#3208. This solves an issue when attempting to access any SettingsModel before initial migrations have been run but the database exists (which is all App::hasDatabase() looks for).
This change allows developers to prevent the CMS route from being registered.
An example use case for this is loading the CMS content under a set path prefix by re-registering the CMS route with the appropriate prefix in place. Preventing the registration of the default CMS route is required in order to override the mapping of the controller action to URL (and thus have the Cms::url() helper generate the correct URLs in this example).
Example:
```php
Route::any('docs/{slug?}', 'Cms\Classes\CmsController@run')->where('slug', '(.*)?')->middleware('web');
Event::listen('cms.beforeRoute', function () {
$path = Request::path();
// Disable the CMS routes so that the docs/ route can take over for URL generation
if (Str::startsWith($path, 'docs')) {
return false;
}
});
```