blob: 436e9ec4add025087853e23928f9a1f885d6eccb (
plain)
| 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
43
44
45
46
47
48
49
50
51
52
53
 | <?php
namespace Lightscale\LaralightSvg;
class SvgService
{
    protected array $collections = [];
    public function __construct()
    {
        $collections = config('svg.collections');
        foreach ($collections as $k => $collection) {
            $this->addCollectionConfig($k, $collection);
        }
    }
    protected function addCollectionFromConfig(
        string $collectionName,
        array $collectionConfig
    ): void
    {
        $c = new SvgCollection($collectionName);
        foreach ($collectionConfig['paths'] as $p) {
            $c->addPath($p);
        }
        $this->addCollection($c);
    }
    public function addCollection(SvgCollection $collection): void
    {
        $this->collections[$collection->getName()] = $collection;
    }
    public function registerCollection(string $collection): void
    {
        $this->addCollection(new SvgCollection($collection));
    }
    public function addCollectionPath(string $collection, string $path): void
    {
        $this->collections[$collection]->addPath($path);
    }
    public function getSvgUrl(string $collection, string $svg): string
    {
        return $this->collections[$collection]->getSvgUrl($collection, $svg);
    }
}
 |