-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefinitionFileContainer.php
76 lines (60 loc) · 1.78 KB
/
definitionFileContainer.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\DIContainerHandler;
use Assert\Assert;
class definitionFileContainer
{
public const TYPE_YAML = 'yml';
protected array $definitionFiles = [
self::TYPE_YAML => [],
];
protected array $allowedTypes = [
self::TYPE_YAML,
];
public function __construct()
{
/** keep clear */
}
public function addDefinitions(string $definitionFile, string $type): void
{
Assert::that($type)->inArray($this->allowedTypes, 'invalid definition file type');
Assert::that(dirname(__FILE__, 3).'/'.$definitionFile)->file('invalid definition file');
$this->definitionFiles[$type][md5($definitionFile)] = $definitionFile;
}
public function addYamlDefinitions(string $definitionFile): void
{
$this->addDefinitions($definitionFile, self::TYPE_YAML);
}
public function getDefinitions(string $type): array
{
Assert::that($type)->inArray($this->allowedTypes, 'invalid definition file type');
return $this->definitionFiles[$type];
}
public function getYamlDefinitions(): array
{
return $this->getDefinitions(self::TYPE_YAML);
}
/**
* @return array[]
*/
public function getAll(): array
{
return $this->definitionFiles;
}
public function clear(): void
{
$this->definitionFiles = [];
}
}