blob: 19c96078595e667ba7a3f2753b7d4d7d13107d8d (
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
54
55
56
57
58
59
60
61
 | <?php
namespace Lightscale\LaralightSvg;
class SvgService
{
    protected array $collections = [];
    public function __construct()
    {
        $collections = config('svg.collections');
        foreach ($collections as $k => $collection) {
            $this->addCollectionFromConfig($k, $collection);
        }
    }
    protected function addCollectionFromConfig(
        string $collectionName,
        array $collectionConfig
    ): void
    {
        $c = new SvgCollection(
            $collectionName,
            $collectionConfig,
        );
        $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($svg);
    }
    public function getCollection(string $collection): ?SvgCollection
    {
        return $this->collections[$collection] ?? null;
    }
    public function getCollections(): array
    {
        return $this->collections;
    }
}
 |