|
1
|
|
|
<?php declare(strict_types = 1); |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: root |
|
5
|
|
|
* Date: 27.07.2016 |
|
6
|
|
|
* Time: 1:55. |
|
7
|
|
|
*/ |
|
8
|
|
|
namespace samsonframework\container\collection; |
|
9
|
|
|
|
|
10
|
|
|
use samsonframework\container\configurator\ClassConfiguratorInterface; |
|
11
|
|
|
use samsonframework\container\configurator\ParameterConfiguratorInterface; |
|
12
|
|
|
use samsonframework\container\configurator\PropertyConfiguratorInterface; |
|
13
|
|
|
use samsonframework\container\metadata\ClassMetadata; |
|
14
|
|
|
use samsonframework\container\metadata\ParameterMetadata; |
|
15
|
|
|
use samsonframework\container\metadata\PropertyMetadata; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class collection configurator class. |
|
19
|
|
|
* |
|
20
|
|
|
* @see \samsonframework\container\configurator\ScopeConfigurator |
|
21
|
|
|
* |
|
22
|
|
|
* @author Vitaly Egorov <[email protected]> |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
class ClassName implements ClassConfiguratorInterface, PropertyConfiguratorInterface, ParameterConfiguratorInterface, CollectionAttributeConfiguratorInterface |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var string Configurator key |
|
29
|
|
|
*/ |
|
30
|
|
|
const CONFIGURATOR_KEY = 'class'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var string Dependency class name |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $className; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Class collection configurator constructor. |
|
39
|
|
|
* |
|
40
|
|
|
* @param string $className Class name |
|
41
|
|
|
*/ |
|
42
|
1 |
|
public function __construct(string $className) |
|
43
|
|
|
{ |
|
44
|
1 |
|
$this->className = $className; |
|
45
|
1 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/* {@inheritDoc} */ |
|
48
|
1 |
|
public function toClassMetadata(ClassMetadata $classMetadata) |
|
49
|
|
|
{ |
|
50
|
1 |
|
$classMetadata->className = $this->className; |
|
51
|
1 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/* {@inheritDoc} */ |
|
54
|
1 |
|
public function toPropertyMetadata(PropertyMetadata $propertyMetadata) |
|
55
|
|
|
{ |
|
56
|
1 |
|
$propertyMetadata->dependency = $this->className; |
|
57
|
1 |
|
} |
|
58
|
|
|
|
|
59
|
|
|
/* {@inheritDoc} */ |
|
60
|
1 |
|
public function toParameterMetadata(ParameterMetadata $parameterMetadata) |
|
61
|
|
|
{ |
|
62
|
1 |
|
$parameterMetadata->dependency = $this->className; |
|
63
|
1 |
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|