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
|
|
|
* *Resolve class attribute, "Class" - name more better but it reserved in php |
25
|
|
|
*/ |
26
|
|
|
class Instance implements ClassConfiguratorInterface, PropertyConfiguratorInterface, ParameterConfiguratorInterface, CollectionAttributeConfiguratorInterface |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var string Configurator key |
30
|
|
|
*/ |
31
|
|
|
const CONFIGURATOR_KEY = 'class'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string Dependency class name |
35
|
|
|
*/ |
36
|
|
|
protected $className; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Class collection configurator constructor. |
40
|
|
|
* |
41
|
|
|
* @param string $className Class name |
42
|
|
|
*/ |
43
|
1 |
|
public function __construct(string $className) |
44
|
|
|
{ |
45
|
1 |
|
$this->className = $className; |
46
|
1 |
|
} |
47
|
|
|
|
48
|
|
|
/* {@inheritDoc} */ |
49
|
1 |
|
public function toClassMetadata(ClassMetadata $classMetadata) |
50
|
|
|
{ |
51
|
1 |
|
$classMetadata->className = $this->className; |
52
|
1 |
|
} |
53
|
|
|
|
54
|
|
|
/* {@inheritDoc} */ |
55
|
1 |
|
public function toPropertyMetadata(PropertyMetadata $propertyMetadata) |
56
|
|
|
{ |
57
|
1 |
|
$propertyMetadata->dependency = $this->className; |
58
|
1 |
|
} |
59
|
|
|
|
60
|
|
|
/* {@inheritDoc} */ |
61
|
1 |
|
public function toParameterMetadata(ParameterMetadata $parameterMetadata) |
62
|
|
|
{ |
63
|
1 |
|
$parameterMetadata->dependency = $this->className; |
64
|
1 |
|
} |
65
|
|
|
} |
66
|
|
|
|