-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResourcePublisher.php
42 lines (33 loc) · 1.15 KB
/
ResourcePublisher.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
namespace Pandawa\Component\Foundation;
use Illuminate\Support\ServiceProvider;
/**
* @author Iqbal Maulana <iq.bluejack@gmail.com>
*/
class ResourcePublisher
{
public static function publishes(string $class, array $paths, string|array $groups = null): void
{
static::ensurePublishArrayInitialized($class);
ServiceProvider::$publishes[$class] = array_merge(ServiceProvider::$publishes[$class], $paths);
foreach ((array)$groups as $group) {
static::addPublishGroup($group, $paths);
}
}
public static function ensurePublishArrayInitialized(string $class): void
{
if (!array_key_exists($class, ServiceProvider::$publishes)) {
ServiceProvider::$publishes[$class] = [];
}
}
public static function addPublishGroup(string $group, array $paths): void
{
if (!array_key_exists($group, ServiceProvider::$publishGroups)) {
ServiceProvider::$publishGroups[$group] = [];
}
ServiceProvider::$publishGroups[$group] = array_merge(
ServiceProvider::$publishGroups[$group], $paths
);
}
}