mirror of
https://github.com/flarum/core.git
synced 2025-07-22 01:01:28 +02:00
fixed container bindings use of container (#2807)
This commit is contained in:
@@ -16,6 +16,7 @@ use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\User\IdSlugDriver;
|
||||
use Flarum\User\User;
|
||||
use Flarum\User\UsernameSlugDriver;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class HttpServiceProvider extends AbstractServiceProvider
|
||||
@@ -29,7 +30,7 @@ class HttpServiceProvider extends AbstractServiceProvider
|
||||
return ['token'];
|
||||
});
|
||||
|
||||
$this->container->bind(Middleware\CheckCsrfToken::class, function ($container) {
|
||||
$this->container->bind(Middleware\CheckCsrfToken::class, function (Container $container) {
|
||||
return new Middleware\CheckCsrfToken($container->make('flarum.http.csrfExemptPaths'));
|
||||
});
|
||||
|
||||
@@ -45,23 +46,23 @@ class HttpServiceProvider extends AbstractServiceProvider
|
||||
];
|
||||
});
|
||||
|
||||
$this->container->singleton('flarum.http.selectedSlugDrivers', function () {
|
||||
$settings = $this->container->make(SettingsRepositoryInterface::class);
|
||||
$this->container->singleton('flarum.http.selectedSlugDrivers', function (Container $container) {
|
||||
$settings = $container->make(SettingsRepositoryInterface::class);
|
||||
|
||||
$compiledDrivers = [];
|
||||
|
||||
foreach ($this->container->make('flarum.http.slugDrivers') as $resourceClass => $resourceDrivers) {
|
||||
foreach ($container->make('flarum.http.slugDrivers') as $resourceClass => $resourceDrivers) {
|
||||
$driverKey = $settings->get("slug_driver_$resourceClass", 'default');
|
||||
|
||||
$driverClass = Arr::get($resourceDrivers, $driverKey, $resourceDrivers['default']);
|
||||
|
||||
$compiledDrivers[$resourceClass] = $this->container->make($driverClass);
|
||||
$compiledDrivers[$resourceClass] = $container->make($driverClass);
|
||||
}
|
||||
|
||||
return $compiledDrivers;
|
||||
});
|
||||
$this->container->bind(SlugManager::class, function () {
|
||||
return new SlugManager($this->container->make('flarum.http.selectedSlugDrivers'));
|
||||
$this->container->bind(SlugManager::class, function (Container $container) {
|
||||
return new SlugManager($container->make('flarum.http.selectedSlugDrivers'));
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user