Completed
Push — master ( d6c5c0...118f52 )
by Thomas
04:57
created

getRelationshipActionNamespace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace keeko\tools\generator\name;
3
4
use keeko\tools\model\Relationship;
5
use Propel\Generator\Model\Table;
6
7
/**
8
 * Generates action class names
9
 * 
10
 * @author gossi
11
 */
12
class ActionClassNameGenerator extends AbstractModelNameGenerator {
13
	
14
	/**
15
	 * Returns the namespace for the model actions
16
	 * 
17
	 * @return string
18
	 */
19
	private function getModelActionNamespace() {
20
		return $this->service->getFactory()->getNamespaceGenerator()->getModelActionNamespace();
21
	}
22
	
23
	/**
24
	 * Returns the namespace for relationship actions
25
	 *
26
	 * @return string
27
	 */
28
	private function getRelationshipActionNamespace() {
29
		return $this->service->getFactory()->getNamespaceGenerator()->getRelationshipActionNamespace();
30
	}
31
	
32
	//
33
	// Model generators
34
	//
35
	
36
	/**
37
	 * Generates the class name for a list action
38
	 *
39
	 * @param Table $model
40
	 * @return string
41
	 */
42
	public function generateModelPaginate(Table $model) {
43
		return sprintf('%s\\%sPaginateAction', $this->getModelActionNamespace(), $model->getPhpName());
44
	}
45
46
	/**
47
	 * Generates the class name for a create action
48
	 * 
49
	 * @param Table $model
50
	 * @return string
51
	 */
52
	public function generateModelCreate(Table $model) {
53
		return sprintf('%s\\%sCreateAction', $this->getModelActionNamespace(), $model->getPhpName());
54
	}
55
56
	/**
57
	 * Generates the class name for a read action
58
	 * 
59
	 * @param Table $model
60
	 * @return string
61
	 */
62
	public function generateModelRead(Table $model) {
63
		return sprintf('%s\\%sReadAction', $this->getModelActionNamespace(), $model->getPhpName());
64
	}
65
66
	/**
67
	 * Generates the class name for an update action
68
	 * 
69
	 * @param Table $model
70
	 * @return string
71
	 */
72
	public function generateModelUpdate(Table $model) {
73
		return sprintf('%s\\%sUpdateAction', $this->getModelActionNamespace(), $model->getPhpName());
74
	}
75
76
	/**
77
	 * Generates the class name for a delete action
78
	 * 
79
	 * @param Table $model
80
	 * @return string
81
	 */
82
	public function generateModelDelete(Table $model) {
83
		return sprintf('%s\\%sDeleteAction', $this->getModelActionNamespace(), $model->getPhpName());
84
	}
85
	
86
	//
87
	// Relationship generators
88
	//
89
90
	/**
91
	 * Generates the class name for a relationship read action
92
	 * 
93
	 * @param Relationship $relationship
94
	 * @return string
95
	 */
96
	public function generateRelationshipRead(Relationship $relationship) {
97
		$model = $relationship->getModel();
98
		return sprintf('%s\\%s%sReadAction', $this->getRelationshipActionNamespace(), 
99
			$model->getPhpName(), $relationship->getRelatedName());
100
	}
101
102
	/**
103
	 * Generates the class name for a relationship update action
104
	 * 
105
	 * @param Relationship $relationship
106
	 * @return string
107
	 */
108
	public function generateRelationshipUpdate(Relationship $relationship) {
109
		$model = $relationship->getModel();
110
		return sprintf('%s\\%s%sUpdateAction', $this->getRelationshipActionNamespace(), 
111
			$model->getPhpName(), $relationship->getRelatedName());
112
	}
113
114
	/**
115
	 * Generates the class name for a relationship add action
116
	 * 
117
	 * @param Relationship $relationship
118
	 * @return string
119
	 */
120
	public function generateRelationshipAdd(Relationship $relationship) {
121
		$model = $relationship->getModel();
122
		return sprintf('%s\\%s%sAddAction', $this->getRelationshipActionNamespace(), 
123
			$model->getPhpName(), $relationship->getRelatedName());
124
	}
125
126
	/**
127
	 * Generates the class name for a relationship remove action
128
	 * 
129
	 * @param Relationship $relationship
130
	 * @return string
131
	 */
132
	public function generateRelationshipRemove(Relationship $relationship) {
133
		$model = $relationship->getModel();
134
		return sprintf('%s\\%s%sRemoveAction', $this->getRelationshipActionNamespace(), 
135
			$model->getPhpName(), $relationship->getRelatedName());
136
	}
137
}