|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items; |
|
4
|
|
|
|
|
5
|
|
|
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\MethodInterface; |
|
6
|
|
|
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\RenderableInterface; |
|
7
|
|
|
use JMS\Serializer\Annotation\Type; |
|
8
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
9
|
|
|
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\Traits\TemplateTrait; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Method Manager |
|
13
|
|
|
* |
|
14
|
|
|
* @author Sławomir Kania <[email protected]> |
|
15
|
|
|
*/ |
|
16
|
|
|
abstract class MethodManager implements RenderableInterface, MethodInterface |
|
17
|
|
|
{ |
|
18
|
|
|
use TemplateTrait; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @Type("HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items\PropertyManager") |
|
22
|
|
|
* @Assert\NotNull(message="Property for method can not be empty!") |
|
23
|
|
|
* @Assert\Valid() |
|
24
|
|
|
*/ |
|
25
|
|
|
private $property = null; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @Assert\NotNull(message="Method has to know about class!") |
|
29
|
|
|
* @Assert\Valid() |
|
30
|
|
|
* @var ClassManager |
|
31
|
|
|
*/ |
|
32
|
|
|
private $classManager = null; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Construct. |
|
36
|
|
|
* |
|
37
|
|
|
* @param ClassManager $classManager |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct(ClassManager $classManager) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->setClassManager($classManager); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return PropertyManager |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getProperty() |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->property; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param PropertyManager $property |
|
54
|
|
|
*/ |
|
55
|
|
|
public function setProperty(PropertyManager $property) |
|
56
|
|
|
{ |
|
57
|
|
|
$this->property = $property; |
|
58
|
|
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Get Base ClassManager |
|
63
|
|
|
* |
|
64
|
|
|
* @return ClassManager |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getClassManager() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->classManager; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Set Base ClassManager |
|
73
|
|
|
* |
|
74
|
|
|
* @param ClassManager $classManager |
|
75
|
|
|
*/ |
|
76
|
|
|
public function setClassManager(ClassManager $classManager) |
|
77
|
|
|
{ |
|
78
|
|
|
$this->classManager = $classManager; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Return prepared method name from property eg. getNameOrSurname |
|
83
|
|
|
* |
|
84
|
|
|
* @return string |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getPreparedName() |
|
87
|
|
|
{ |
|
88
|
|
|
return ucfirst($this->getProperty()->getPreparedName()); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Return set of tags used in template |
|
93
|
|
|
* |
|
94
|
|
|
* @return array |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getTemplateTags() |
|
97
|
|
|
{ |
|
98
|
|
|
// to override |
|
99
|
|
|
return []; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|