1
|
|
|
<?php |
2
|
|
|
namespace keeko\tools\generator\name; |
3
|
|
|
|
4
|
|
|
class NamespaceGenerator extends AbstractNameGenerator { |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Returns the namespace for an action |
8
|
|
|
* |
9
|
|
|
* @return string |
10
|
|
|
*/ |
11
|
|
|
public function getActionNamespace() { |
12
|
|
|
return $this->service->getPackageService()->getNamespace() . '\\action'; |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Returns the namespace for a model action |
17
|
|
|
* |
18
|
|
|
* @return string |
19
|
|
|
*/ |
20
|
|
|
public function getModelActionNamespace() { |
21
|
|
|
return $this->getActionNamespace() . '\\model'; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Returns the namespace for a relationship action |
26
|
|
|
* |
27
|
|
|
* @return string |
28
|
|
|
*/ |
29
|
|
|
public function getRelationshipActionNamespace() { |
30
|
|
|
return $this->getActionNamespace() . '\\relationship'; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Returns the namespace for a responder |
35
|
|
|
* |
36
|
|
|
* @return string |
37
|
|
|
*/ |
38
|
|
|
public function getResponderNamespace() { |
39
|
|
|
return $this->service->getPackageService()->getNamespace() . '\\responder'; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Returns the namespace for a responder with a given format |
44
|
|
|
* |
45
|
|
|
* @param string $format |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getResponderNamespaceByFormat($format) { |
49
|
|
|
return $this->getResponderNamespace() . '\\' . strtolower($format); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Returns the namespace for a json responder |
54
|
|
|
* |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
|
|
public function getJsonResponderNamespace() { |
58
|
|
|
return $this->getResponderNamespaceByFormat('json'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Returns the namespace for a html responder |
63
|
|
|
* |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function getHtmlResponderNamespace() { |
67
|
|
|
return $this->getResponderNamespaceByFormat('html'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Returns the namespace for a model responder with a given format |
72
|
|
|
* |
73
|
|
|
* @param string $format |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function getModelResponderNamespace($format) { |
77
|
|
|
return $this->getResponderNamespaceByFormat($format) . '\\model'; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Returns the namespace for a json model responder |
82
|
|
|
* |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
|
|
public function getJsonModelResponderNamespace() { |
86
|
|
|
return $this->getJsonResponderNamespace() . '\\model'; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Returns the namespace for a html model responder |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getHtmlModelResponderNamespace() { |
95
|
|
|
return $this->getHtmlResponderNamespace() . '\\model'; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Returns the namespace for a responder with a given format |
100
|
|
|
* |
101
|
|
|
* @param string $format |
102
|
|
|
* @return string |
103
|
|
|
*/ |
104
|
|
|
public function getRelationshipResponderNamespace($format) { |
105
|
|
|
return $this->getResponderNamespaceByFormat($format) . '\\relationship'; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Returns the namespace for a json relationship responder |
110
|
|
|
* |
111
|
|
|
* @return string |
112
|
|
|
*/ |
113
|
|
|
public function getJsonRelationshipResponderNamespace() { |
114
|
|
|
return $this->getJsonResponderNamespace() . '\\relationship'; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Returns the namespace for a html relationship responder |
119
|
|
|
* |
120
|
|
|
* @return string |
121
|
|
|
*/ |
122
|
|
|
public function getHtmlRelationshipResponderNamespace() { |
123
|
|
|
return $this->getHtmlResponderNamespace() . '\\relationship'; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Returns the namespace for a domain |
128
|
|
|
* |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
|
|
public function getDomainNamespace() { |
132
|
|
|
return $this->service->getPackageService()->getNamespace() . '\\domain'; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|