1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This software package is licensed under AGPL, Commercial license. |
5
|
|
|
* |
6
|
|
|
* @package maslosoft/addendum |
7
|
|
|
* @licence AGPL, Commercial |
8
|
|
|
* @copyright Copyright (c) Piotr Masełkowski <[email protected]> (Meta container, further improvements, bugfixes) |
9
|
|
|
* @copyright Copyright (c) Maslosoft (Meta container, further improvements, bugfixes) |
10
|
|
|
* @copyright Copyright (c) Jan Suchal (Original version, builder, parser) |
11
|
|
|
* @link http://maslosoft.com/addendum/ - maslosoft addendum |
12
|
|
|
* @link https://code.google.com/p/addendum/ - original addendum project |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Maslosoft\Addendum\Collections; |
16
|
|
|
|
17
|
|
|
use Maslosoft\Addendum\Annotation; |
18
|
|
|
use Maslosoft\Addendum\Interfaces\AnnotationEntityInterface; |
19
|
|
|
use Maslosoft\Addendum\Interfaces\MetaAnnotationInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Annotation used for Collections\Meta |
23
|
|
|
* @author Piotr |
24
|
|
|
*/ |
25
|
|
|
abstract class MetaAnnotation extends Annotation implements MetaAnnotationInterface |
26
|
|
|
{ |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Name of annotated field/method/class |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
public $name = ''; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Model metadata object |
36
|
|
|
* |
37
|
|
|
* NOTE: Deprecation notice is only to discourage direct use in annotations, this is actually required |
38
|
|
|
* @deprecated Use getMeta() instead |
39
|
|
|
* |
40
|
|
|
* @var Meta |
41
|
|
|
*/ |
42
|
|
|
private $_meta = null; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Annotations entity, it can be either class, property, or method |
46
|
|
|
* Its concrete annotation implementation responsibility to decide what to do with it. |
47
|
|
|
* |
48
|
|
|
* NOTE: Deprecation notice is only to discourage direct use in annotations, this is actually required |
49
|
|
|
* @deprecated Use getEntity() instead |
50
|
|
|
* |
51
|
|
|
* @var AnnotationEntityInterface |
52
|
|
|
*/ |
53
|
|
|
private $_entity = null; |
54
|
|
|
|
55
|
22 |
|
public function setName($name) |
56
|
|
|
{ |
57
|
22 |
|
$this->name = $name; |
58
|
22 |
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Set metadata class to be accessible for annotation for init etc. methods |
62
|
|
|
* @param Meta $meta |
63
|
|
|
*/ |
64
|
22 |
|
public function setMeta(Meta $meta) |
65
|
|
|
{ |
66
|
22 |
|
$this->_meta = $meta; |
67
|
22 |
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get metadata class for whole entity. |
71
|
|
|
* |
72
|
|
|
* This allows access to type, method or property in any annotation, |
73
|
|
|
* regardles of it's location. |
74
|
|
|
* |
75
|
|
|
* @return Meta |
76
|
|
|
*/ |
77
|
|
|
public function getMeta() |
78
|
|
|
{ |
79
|
|
|
return $this->_meta; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Set annotatins entity, it can be either class, property, or method |
84
|
|
|
* @param AnnotationEntityInterface $entity |
85
|
|
|
*/ |
86
|
22 |
|
public function setEntity(AnnotationEntityInterface $entity) |
87
|
|
|
{ |
88
|
22 |
|
$this->_entity = $entity; |
89
|
22 |
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Get annotated entity. |
93
|
|
|
* |
94
|
|
|
* Use this in annotations definitions to define it's params, ie: |
95
|
|
|
* |
96
|
|
|
* ```php |
97
|
|
|
* public function init() |
98
|
|
|
* { |
99
|
|
|
* $this->getEntity()->someValue = $this->value; |
100
|
|
|
* } |
101
|
|
|
* ``` |
102
|
|
|
* |
103
|
|
|
* @return AnnotatedEntityInteface |
104
|
|
|
*/ |
105
|
22 |
|
public function getEntity() |
106
|
|
|
{ |
107
|
22 |
|
return $this->_entity; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* This function should be called after all annotations are initialized. |
112
|
|
|
* Any code that depends on other annotations can be executed here. |
113
|
|
|
* NOTE: This is not ensured to run, its annotations container responsibility to call it. |
114
|
|
|
* @deprecated since version number 5 |
115
|
|
|
*/ |
116
|
|
|
public function afterInit() |
117
|
|
|
{ |
118
|
|
|
|
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
} |
122
|
|
|
|