1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* YAWIK |
4
|
|
|
* |
5
|
|
|
* @filesource |
6
|
|
|
* @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de) |
7
|
|
|
* @license MIT |
8
|
|
|
* @author [email protected] |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Jobs\Filter; |
13
|
|
|
|
14
|
|
|
use Jobs\Entity\Job; |
15
|
|
|
use Zend\Filter\FilterInterface; |
16
|
|
|
use Zend\View\Model\ViewModel; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* assembles a viewModel for Templates |
20
|
|
|
* this class needs to be extended for specific assignments |
21
|
|
|
* Class viewModelTemplateFilterAbstract |
22
|
|
|
* @package Jobs\Filter |
23
|
|
|
*/ |
24
|
|
|
abstract class viewModelTemplateFilterAbstract implements FilterInterface |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var array assemples all data for the viewmodel |
29
|
|
|
*/ |
30
|
|
|
protected $container; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var Job |
34
|
|
|
*/ |
35
|
|
|
protected $job; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
protected $config; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* creating absolute links like the apply-link |
44
|
|
|
* absolute links are needed on the server of the provider |
45
|
|
|
* @var |
46
|
|
|
*/ |
47
|
|
|
protected $urlPlugin; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* also needed to create absolute links |
51
|
|
|
* @var |
52
|
|
|
*/ |
53
|
|
|
protected $basePathHelper; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var |
57
|
|
|
*/ |
58
|
|
|
protected $serverUrlHelper; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param $config |
62
|
|
|
*/ |
63
|
|
|
public function setConfig($config) |
64
|
|
|
{ |
65
|
|
|
$this->config = $config; |
66
|
|
|
return; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param $urlPlugin |
71
|
|
|
*/ |
72
|
|
|
public function setUrlPlugin($urlPlugin) |
73
|
|
|
{ |
74
|
|
|
$this->urlPlugin = $urlPlugin; |
75
|
|
|
return; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param $basePathHelper |
80
|
|
|
*/ |
81
|
|
|
public function setBasePathHelper($basePathHelper) |
82
|
|
|
{ |
83
|
|
|
$this->basePathHelper = $basePathHelper; |
84
|
|
|
return; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return mixed |
89
|
|
|
*/ |
90
|
|
|
public function getBasePathHelper() |
91
|
|
|
{ |
92
|
|
|
return $this->basePathHelper; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param $serverUrlHelper |
97
|
|
|
*/ |
98
|
|
|
public function setServerUrlHelper($serverUrlHelper) |
99
|
|
|
{ |
100
|
|
|
$this->serverUrlHelper = $serverUrlHelper; |
101
|
|
|
return; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return mixed |
106
|
|
|
*/ |
107
|
|
|
public function getServerUrlHelper() |
108
|
|
|
{ |
109
|
|
|
return $this->serverUrlHelper; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param mixed $value |
114
|
|
|
* @return mixed|ViewModel |
115
|
|
|
* @throws \InvalidArgumentException |
116
|
|
|
*/ |
117
|
|
|
public function filter($value) |
118
|
|
|
{ |
119
|
|
|
$model = new ViewModel(); |
120
|
|
|
$this->container = array(); |
121
|
|
|
$this->extract($value); |
122
|
|
|
$model->setVariables($this->container); |
123
|
|
|
if (!isset($this->job)) { |
124
|
|
|
throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job'); |
125
|
|
|
} |
126
|
|
|
$model->setTemplate('templates/' . $this->job->template . '/index'); |
|
|
|
|
127
|
|
|
return $model; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* should be overwritten |
132
|
|
|
* here are all assignments to container arr administered |
133
|
|
|
* input-attributes are the job and the configuration |
134
|
|
|
* output-attribute is the container |
135
|
|
|
* @param $value |
136
|
|
|
* @return mixed |
137
|
|
|
*/ |
138
|
|
|
abstract protected function extract($value); |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return $this |
142
|
|
|
* @throws \InvalidArgumentException |
143
|
|
|
*/ |
144
|
|
|
protected function setUriApply() |
145
|
|
|
{ |
146
|
|
|
if (!isset($this->job)) { |
147
|
|
|
throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job'); |
148
|
|
|
} |
149
|
|
|
$atsMode = $this->job->getAtsMode(); |
150
|
|
|
$uriApply = false; |
151
|
|
|
if ($atsMode->isIntern() || $atsMode->isEmail()) { |
152
|
|
|
$uriApply = $this->urlPlugin->fromRoute('lang/apply', array('applyId' => $this->job->applyId), array('force_canonical' => true)); |
|
|
|
|
153
|
|
|
} elseif ($atsMode->isUri()) { |
154
|
|
|
$uriApply = $atsMode->getUri(); |
155
|
|
|
} |
156
|
|
|
$this->container['uriApply'] = $uriApply; |
157
|
|
|
return $this; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @return $this |
162
|
|
|
* @throws \InvalidArgumentException |
163
|
|
|
*/ |
164
|
|
|
protected function setLocation() |
165
|
|
|
{ |
166
|
|
|
if (!isset($this->job)) { |
167
|
|
|
throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job'); |
168
|
|
|
} |
169
|
|
|
$location = $this->job->getLocation(); |
170
|
|
|
$this->container['location'] = isset($location)?$location:''; |
171
|
|
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Sets the company description of a job. Use the description of an organization as default |
176
|
|
|
* |
177
|
|
|
* @return $this |
178
|
|
|
* @throws \InvalidArgumentException |
179
|
|
|
*/ |
180
|
|
|
protected function setDescription() |
181
|
|
|
{ |
182
|
|
|
if (!isset($this->job)) { |
183
|
|
|
throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job'); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
if (empty($this->job->templateValues->description) && isset($this->job->organization)) { |
|
|
|
|
187
|
|
|
$this->job->templateValues->description = $this->job->organization->description; |
|
|
|
|
188
|
|
|
} |
189
|
|
|
$description = $this->job->templateValues->description; |
|
|
|
|
190
|
|
|
|
191
|
|
|
$this->container['description'] = isset($description)?$description:''; |
192
|
|
|
return $this; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @return $this |
197
|
|
|
* @throws \InvalidArgumentException |
198
|
|
|
*/ |
199
|
|
|
protected function setOrganizationInfo() |
200
|
|
|
{ |
201
|
|
|
if (!isset($this->job)) { |
202
|
|
|
throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job'); |
203
|
|
|
} |
204
|
|
|
$organizationName = ''; |
205
|
|
|
$organizationStreet = ''; |
206
|
|
|
$organizationPostalCode = ''; |
207
|
|
|
$organizationPostalCity = ''; |
208
|
|
|
$organization = $this->job->organization; |
|
|
|
|
209
|
|
|
if (isset($organization)) { |
210
|
|
|
$organizationName = $organization->organizationName->name; |
|
|
|
|
211
|
|
|
$organizationStreet = $organization->contact->street.' '.$organization->contact->houseNumber; |
|
|
|
|
212
|
|
|
$organizationPostalCode = $organization->contact->postalcode; |
|
|
|
|
213
|
|
|
$organizationPostalCity = $organization->contact->city; |
|
|
|
|
214
|
|
|
} |
215
|
|
|
$this->container['organizationName'] = $organizationName; |
216
|
|
|
$this->container['street'] = $organizationStreet; |
217
|
|
|
$this->container['postalCode'] = $organizationPostalCode; |
218
|
|
|
$this->container['city'] = $organizationPostalCity; |
219
|
|
|
|
220
|
|
|
if (isset($organization) && isset($organization->image) && $organization->image->uri) { |
|
|
|
|
221
|
|
|
$this->container['uriLogo'] = $this->makeAbsolutePath($organization->image->uri); |
|
|
|
|
222
|
|
|
} else { |
223
|
|
|
$this->container['uriLogo'] = $this->makeAbsolutePath($this->config->default_logo); |
224
|
|
|
} |
225
|
|
|
return $this; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @return $this |
230
|
|
|
*/ |
231
|
|
|
protected function setTemplate() |
232
|
|
|
{ |
233
|
|
|
$this->container['templateName'] = $this->job->template; |
|
|
|
|
234
|
|
|
return $this; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* combines two helper |
239
|
|
|
* @param $path |
240
|
|
|
* @return mixed |
241
|
|
|
*/ |
242
|
|
|
protected function makeAbsolutePath($path) |
243
|
|
|
{ |
244
|
|
|
$path = $this->serverUrlHelper->__invoke($this->basePathHelper->__invoke($path)); |
245
|
|
|
return $path; |
246
|
|
|
} |
247
|
|
|
} |
248
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.