| 1 |
<?php |
| 2 |
|
| 3 |
namespace Illuminate\Support; |
| 4 |
|
| 5 |
class DefaultProviders |
| 6 |
{ |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
protected $providers; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
public function __construct(?array $providers = null) |
| 18 |
{ |
| 19 |
$this->providers = $providers ?: [ |
| 20 |
\Illuminate\Auth\AuthServiceProvider::class, |
| 21 |
\Illuminate\Broadcasting\BroadcastServiceProvider::class, |
| 22 |
\Illuminate\Bus\BusServiceProvider::class, |
| 23 |
\Illuminate\Cache\CacheServiceProvider::class, |
| 24 |
\Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, |
| 25 |
\Illuminate\Concurrency\ConcurrencyServiceProvider::class, |
| 26 |
\Illuminate\Cookie\CookieServiceProvider::class, |
| 27 |
\Illuminate\Database\DatabaseServiceProvider::class, |
| 28 |
\Illuminate\Encryption\EncryptionServiceProvider::class, |
| 29 |
\Illuminate\Filesystem\FilesystemServiceProvider::class, |
| 30 |
\Illuminate\Foundation\Providers\FoundationServiceProvider::class, |
| 31 |
\Illuminate\Hashing\HashServiceProvider::class, |
| 32 |
\Illuminate\Mail\MailServiceProvider::class, |
| 33 |
\Illuminate\Notifications\NotificationServiceProvider::class, |
| 34 |
\Illuminate\Pagination\PaginationServiceProvider::class, |
| 35 |
\Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, |
| 36 |
\Illuminate\Pipeline\PipelineServiceProvider::class, |
| 37 |
\Illuminate\Queue\QueueServiceProvider::class, |
| 38 |
\Illuminate\Redis\RedisServiceProvider::class, |
| 39 |
\Illuminate\Session\SessionServiceProvider::class, |
| 40 |
\Illuminate\Translation\TranslationServiceProvider::class, |
| 41 |
\Illuminate\Validation\ValidationServiceProvider::class, |
| 42 |
\Illuminate\View\ViewServiceProvider::class, |
| 43 |
]; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public function merge(array $providers) |
| 53 |
{ |
| 54 |
$this->providers = array_merge($this->providers, $providers); |
| 55 |
|
| 56 |
return new static($this->providers); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
public function replace(array $replacements) |
| 66 |
{ |
| 67 |
$current = new Collection($this->providers); |
| 68 |
|
| 69 |
foreach ($replacements as $from => $to) { |
| 70 |
$key = $current->search($from); |
| 71 |
|
| 72 |
$current = is_int($key) ? $current->replace([$key => $to]) : $current; |
| 73 |
} |
| 74 |
|
| 75 |
return new static($current->values()->toArray()); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
public function except(array $providers) |
| 85 |
{ |
| 86 |
return new static((new Collection($this->providers)) |
| 87 |
->reject(fn ($p) => in_array($p, $providers)) |
| 88 |
->values() |
| 89 |
->toArray()); |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public function toArray() |
| 98 |
{ |
| 99 |
return $this->providers; |
| 100 |
} |
| 101 |
} |