1
0
mirror of https://github.com/flarum/core.git synced 2025-10-17 09:46:14 +02:00
Files
php-flarum/src/Install/InstallServiceProvider.php
Franz Liedke 88366fe8af Clean up usages / deprecate path helpers (#2155)
* Write source map without creating temp file

Less I/O, and one less place where we access the global path helpers.

* Drop useless app_path() helper

This was probably taken straight from Laravel. There is no equivalent
concept in Flarum, so this should be safe to remove.

* Deprecate global path helpers

Developers using these helpers can inject the `Paths` class instead.

* Stop storing paths as strings in container

* Avoid using path helpers from Application class

* Deprecate path helpers from Application class

* Avoid using public_path() in prerequisite check

a) The comparison was already outdated, as a different path was passed.
b) We're trying to get rid of these global helpers.
2020-06-19 16:16:03 -04:00

58 lines
1.3 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Install;
use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Http\RouteCollection;
use Flarum\Http\RouteHandlerFactory;
class InstallServiceProvider extends AbstractServiceProvider
{
/**
* {@inheritdoc}
*/
public function register()
{
$this->app->singleton('flarum.install.routes', function () {
return new RouteCollection;
});
}
/**
* {@inheritdoc}
*/
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../../views/install', 'flarum.install');
$this->populateRoutes($this->app->make('flarum.install.routes'));
}
/**
* @param RouteCollection $routes
*/
protected function populateRoutes(RouteCollection $routes)
{
$route = $this->app->make(RouteHandlerFactory::class);
$routes->get(
'/{path:.*}',
'index',
$route->toController(Controller\IndexController::class)
);
$routes->post(
'/{path:.*}',
'install',
$route->toController(Controller\InstallController::class)
);
}
}