1
0
mirror of https://github.com/flarum/core.git synced 2025-08-12 11:24:30 +02:00

Add Service Provider Extender (#2437)

This commit is contained in:
Sami Mazouz
2020-11-06 19:30:10 +01:00
committed by GitHub
parent f0e77a5789
commit 529d2edcaf
2 changed files with 159 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?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\Extend;
use Flarum\Extension\Extension;
use Illuminate\Contracts\Container\Container;
class ServiceProvider implements ExtenderInterface
{
private $providers = [];
/**
* Register a service provider.
*
* @param string $serviceProviderClass The ::class attribute of the service provider class.
* @return self
*/
public function register(string $serviceProviderClass)
{
$this->providers[] = $serviceProviderClass;
return $this;
}
public function extend(Container $container, Extension $extension = null)
{
$app = $container->make('flarum');
foreach ($this->providers as $provider) {
$app->register($provider);
}
}
}