@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | ], |
20 | 20 | ], |
21 | 21 | 'annotation' => [ |
22 | - 'paths' => [ __DIR__ . '/../src/Entity'] |
|
22 | + 'paths' => [ __DIR__ . '/../src/Entity' ] |
|
23 | 23 | ], |
24 | 24 | ], |
25 | 25 | ], |
@@ -64,6 +64,6 @@ discard block |
||
64 | 64 | ], |
65 | 65 | 'lazy' => true, |
66 | 66 | ], |
67 | - ]], |
|
67 | + ] ], |
|
68 | 68 | ], |
69 | 69 | ]; |
@@ -55,7 +55,7 @@ |
||
55 | 55 | |
56 | 56 | $job = $event->getJobEntity(); |
57 | 57 | $options = $event->getParam('extraData'); |
58 | - $options = isset($options[ 'channels' ][ 'stackoverflow' ]) ? $options[ 'channels' ][ 'stackoverflow' ] : []; |
|
58 | + $options = isset($options[ 'channels' ][ 'stackoverflow' ]) ? $options[ 'channels' ][ 'stackoverflow' ] : [ ]; |
|
59 | 59 | |
60 | 60 | return $this->createResponse($this->manager->send($job, $options)); |
61 | 61 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | public function __call($method, $args) |
62 | 62 | { |
63 | 63 | $response = $this->getResponse(); |
64 | - $callback = [$response, $method]; |
|
64 | + $callback = [ $response, $method ]; |
|
65 | 65 | |
66 | 66 | if (is_callable($callback)) { |
67 | 67 | $returned = call_user_func_array($callback, $args); |
@@ -64,36 +64,36 @@ |
||
64 | 64 | $log->info('Send Job: ' . $job->getId()); |
65 | 65 | $status = true; |
66 | 66 | |
67 | - $jobData = $job->hasAttachedEntity('stackoverflow') ? $job->getAttachedEntity('stackoverflow') : $job->createAttachedEntity(JobData::class, ['jobId' => $job->getId()], 'stackoverflow'); |
|
67 | + $jobData = $job->hasAttachedEntity('stackoverflow') ? $job->getAttachedEntity('stackoverflow') : $job->createAttachedEntity(JobData::class, [ 'jobId' => $job->getId() ], 'stackoverflow'); |
|
68 | 68 | |
69 | 69 | if ($jobData->isOnline()) { |
70 | - $data['action'] = 'put'; |
|
71 | - $data['externalId'] = $jobData->getExternalId(); |
|
70 | + $data[ 'action' ] = 'put'; |
|
71 | + $data[ 'externalId' ] = $jobData->getExternalId(); |
|
72 | 72 | $log->debug('--> Job is already online: External id ' . $jobData->getExternalId() . ': update'); |
73 | 73 | } else { |
74 | - $data['action'] = 'post'; |
|
74 | + $data[ 'action' ] = 'post'; |
|
75 | 75 | $log->debug('--> Job is not online: insert'); |
76 | 76 | } |
77 | 77 | |
78 | - $log->debug('--> data:' , $data); |
|
78 | + $log->debug('--> data:', $data); |
|
79 | 79 | $response = $this->client->sendJob($job, $data); |
80 | 80 | |
81 | 81 | $apiResponse = new ApiResponse($response); |
82 | 82 | |
83 | - $result = $response->getXml(); |
|
83 | + $result = $response->getXml(); |
|
84 | 84 | if ($result) { |
85 | 85 | //$result = $result->response; |
86 | 86 | if ('success' == $result->result) { |
87 | 87 | $jobData->setExternalId($result->jobid) |
88 | 88 | ->setExternalUrl($result->joburl) |
89 | 89 | ->setIsOnline(true); |
90 | - $log->info('==> Successfully send ' . $job->getId(), ['id' => $result->jobid, 'url' => $result->joburl]); |
|
90 | + $log->info('==> Successfully send ' . $job->getId(), [ 'id' => $result->jobid, 'url' => $result->joburl ]); |
|
91 | 91 | |
92 | 92 | } else { |
93 | 93 | $status = false; |
94 | 94 | $log->err('==> Sending job ' . $job->getId() . ' failed.'); |
95 | 95 | $errors = (array) $result->errors->error; |
96 | - $log->debug($response->getStatusCode() . ': ' . $response->getReasonPhrase(), ['errors' => $errors, 'body' => $response->getBody()]); |
|
96 | + $log->debug($response->getStatusCode() . ': ' . $response->getReasonPhrase(), [ 'errors' => $errors, 'body' => $response->getBody() ]); |
|
97 | 97 | } |
98 | 98 | } else { |
99 | 99 | $status = false; |
@@ -10,7 +10,6 @@ |
||
10 | 10 | /** */ |
11 | 11 | namespace StackoverflowApi\Service; |
12 | 12 | |
13 | -use Doctrine\ODM\MongoDB\DocumentRepository; |
|
14 | 13 | use Jobs\Entity\JobInterface; |
15 | 14 | use StackoverflowApi\Client\Client; |
16 | 15 | use StackoverflowApi\Entity\ApiResponse; |
@@ -82,7 +82,7 @@ |
||
82 | 82 | * ], |
83 | 83 | * ] |
84 | 84 | * |
85 | - * @param \DOMDocument|\DOMElement $node |
|
85 | + * @param \DOMDocument $node |
|
86 | 86 | * @param array $specs |
87 | 87 | */ |
88 | 88 | private static function build($node, array $specs) |
@@ -104,19 +104,19 @@ |
||
104 | 104 | $name = '_text'; |
105 | 105 | } |
106 | 106 | } else if (0 === strpos($name, ':')) { |
107 | - $spec = ['_cdata' => $spec]; |
|
107 | + $spec = [ '_cdata' => $spec ]; |
|
108 | 108 | $name = substr($name, 1); |
109 | 109 | } else if (0 === strpos($spec, ':')) { |
110 | - $spec = ['_cdata' => substr($spec, 1)]; |
|
110 | + $spec = [ '_cdata' => substr($spec, 1) ]; |
|
111 | 111 | } else { |
112 | - $spec = ['_text' => $spec]; |
|
112 | + $spec = [ '_text' => $spec ]; |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | if (is_array($spec)) { |
117 | 117 | if (isset($spec[ 0 ]) && !is_string($spec[ 0 ])) { |
118 | 118 | foreach ($spec as $s) { |
119 | - self::build($node, [$name => $s]); |
|
119 | + self::build($node, [ $name => $s ]); |
|
120 | 120 | } |
121 | 121 | continue; |
122 | 122 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | |
37 | 37 | $body = $dom->getElementsByTagName('body')->item(0); |
38 | 38 | |
39 | - foreach (['script', 'style'] as $name) { |
|
39 | + foreach ([ 'script', 'style' ] as $name) { |
|
40 | 40 | while ($elem = $body->getElementsByTagName($name)->item(0)) { |
41 | 41 | $elem->parentNode->removeChild($elem); |
42 | 42 | } |
@@ -11,7 +11,6 @@ |
||
11 | 11 | namespace StackoverflowApi\Client; |
12 | 12 | |
13 | 13 | use Core\Entity\Collection\ArrayCollection; |
14 | -use Jobs\Entity\CoordinatesInterface; |
|
15 | 14 | use Jobs\Entity\JobInterface; |
16 | 15 | use Jobs\Entity\Location; |
17 | 16 | use Jobs\View\Helper\ApplyUrl; |
@@ -152,72 +152,72 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return string |
154 | 154 | */ |
155 | - public function transform(JobInterface $job, $options = []) |
|
155 | + public function transform(JobInterface $job, $options = [ ]) |
|
156 | 156 | { |
157 | 157 | $applyUrl = $this->getApplyUrlHelper(); |
158 | 158 | $serverUrl = $this->getServerUrlHelper(); |
159 | 159 | $imageManager = $this->getOrganizationImageManager(); |
160 | 160 | |
161 | 161 | $jobSpec = [ |
162 | - 'action' => isset($options['action']) ? $options['action'] : 'post', |
|
162 | + 'action' => isset($options[ 'action' ]) ? $options[ 'action' ] : 'post', |
|
163 | 163 | //'test' => 'true', |
164 | 164 | |
165 | 165 | ]; |
166 | 166 | |
167 | - if (isset($options['externalId'])) { |
|
168 | - $jobSpec['jobid'] = $options['externalId']; |
|
167 | + if (isset($options[ 'externalId' ])) { |
|
168 | + $jobSpec[ 'jobid' ] = $options[ 'externalId' ]; |
|
169 | 169 | } |
170 | 170 | |
171 | - $jobSpec[':title'] = $job->getTitle(); |
|
172 | - $jobSpec[':company'] = $job->getOrganization()->getOrganizationName()->getName(); |
|
173 | - $jobSpec[':companyurl'] = $job->getOrganization()->getContact()->getWebsite() ?: ''; |
|
171 | + $jobSpec[ ':title' ] = $job->getTitle(); |
|
172 | + $jobSpec[ ':company' ] = $job->getOrganization()->getOrganizationName()->getName(); |
|
173 | + $jobSpec[ ':companyurl' ] = $job->getOrganization()->getContact()->getWebsite() ?: ''; |
|
174 | 174 | |
175 | 175 | if (($image = $job->getOrganization()->getImage()) && $serverUrl && $imageManager) { |
176 | 176 | $imageUri = $imageManager->getUri($image); |
177 | - $jobSpec['logourl'] = $serverUrl($imageUri); |
|
177 | + $jobSpec[ 'logourl' ] = $serverUrl($imageUri); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | if ($companyDesc = $job->getOrganization()->getDescription()) { |
181 | - $jobSpec[':aboutcompany'] = $companyDesc; |
|
181 | + $jobSpec[ ':aboutcompany' ] = $companyDesc; |
|
182 | 182 | } |
183 | 183 | |
184 | - $jobSpec['vendorid'] = $job->getId(); |
|
184 | + $jobSpec[ 'vendorid' ] = $job->getId(); |
|
185 | 185 | |
186 | - if (!empty($data['applyUrl'])) { |
|
187 | - $jobSpec['howtoapply'] = $data['applyUrl']; |
|
186 | + if (!empty($data[ 'applyUrl' ])) { |
|
187 | + $jobSpec[ 'howtoapply' ] = $data[ 'applyUrl' ]; |
|
188 | 188 | } else if ($contactEmail = $job->getContactEmail()) { |
189 | - $jobSpec['howtoapply'] = $contactEmail; |
|
189 | + $jobSpec[ 'howtoapply' ] = $contactEmail; |
|
190 | 190 | } else { |
191 | 191 | $atsMode = $job->getAtsMode(); |
192 | 192 | if ($atsMode->isDisabled()) { |
193 | - $jobSpec['howtoapply'] = 'postalisch'; |
|
193 | + $jobSpec[ 'howtoapply' ] = 'postalisch'; |
|
194 | 194 | } else if ($atsMode->isEmail()) { |
195 | - $jobSpec['howtoapply'] = $atsMode->getEmail(); |
|
195 | + $jobSpec[ 'howtoapply' ] = $atsMode->getEmail(); |
|
196 | 196 | } else if ($atsMode->isUri()) { |
197 | - $jobSpec['howtoapply'] = $atsMode->getUri(); |
|
197 | + $jobSpec[ 'howtoapply' ] = $atsMode->getUri(); |
|
198 | 198 | } else if (is_callable($applyUrl) && $serverUrl) { |
199 | - $jobSpec['howtoapply'] = $serverUrl($applyUrl($job, ['linkOnly' => true, 'absolute' => true])); |
|
199 | + $jobSpec[ 'howtoapply' ] = $serverUrl($applyUrl($job, [ 'linkOnly' => true, 'absolute' => true ])); |
|
200 | 200 | } else { |
201 | - $jobSpec['howtoapply'] = 'postalisch'; |
|
201 | + $jobSpec[ 'howtoapply' ] = 'postalisch'; |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | 205 | |
206 | 206 | |
207 | 207 | /* Location override by additional data */ |
208 | - if (isset($options['location'])) { |
|
209 | - $location = new Location($options['location']); |
|
210 | - $locations = new ArrayCollection([$location]); |
|
208 | + if (isset($options[ 'location' ])) { |
|
209 | + $location = new Location($options[ 'location' ]); |
|
210 | + $locations = new ArrayCollection([ $location ]); |
|
211 | 211 | } else { |
212 | 212 | $locations = $job->getLocations(); |
213 | 213 | } |
214 | 214 | |
215 | 215 | if ($locations->count()) { |
216 | - $loc = []; |
|
216 | + $loc = [ ]; |
|
217 | 217 | |
218 | 218 | foreach ($locations as $location) { |
219 | 219 | /* \Jobs\Entity\Location $location */ |
220 | - $tmpLoc = []; |
|
220 | + $tmpLoc = [ ]; |
|
221 | 221 | $coords = $location->getCoordinates(); |
222 | 222 | $postalCode = $location->getPostalCode(); |
223 | 223 | $city = $location->getCity(); |
@@ -231,65 +231,65 @@ discard block |
||
231 | 231 | if ($country) { $str .= ', ' . $country; } |
232 | 232 | |
233 | 233 | |
234 | - $tmpLoc['_text'] = $str; |
|
234 | + $tmpLoc[ '_text' ] = $str; |
|
235 | 235 | if ($coords) { |
236 | 236 | $coords = $coords->getCoordinates(); |
237 | - $tmpLoc['@lon'] = str_replace(',', '.', (string) $coords[0]); |
|
238 | - $tmpLoc['@lat'] = str_replace(',', '.', (string) $coords[1]); |
|
237 | + $tmpLoc[ '@lon' ] = str_replace(',', '.', (string) $coords[ 0 ]); |
|
238 | + $tmpLoc[ '@lat' ] = str_replace(',', '.', (string) $coords[ 1 ]); |
|
239 | 239 | } |
240 | 240 | |
241 | - $loc[] = $tmpLoc; |
|
241 | + $loc[ ] = $tmpLoc; |
|
242 | 242 | } |
243 | 243 | |
244 | - $jobSpec['locations']['location'] = $loc; |
|
244 | + $jobSpec[ 'locations' ][ 'location' ] = $loc; |
|
245 | 245 | } |
246 | 246 | |
247 | - foreach (['topspot', 'featured', 'remote', 'relocation', 'visasponsorship', 'sysadmin'] as $boolOpt) { |
|
248 | - if (isset($options[$boolOpt])) { |
|
249 | - $jobSpec[$boolOpt] = $options[$boolOpt] ? 'true' : 'false'; |
|
247 | + foreach ([ 'topspot', 'featured', 'remote', 'relocation', 'visasponsorship', 'sysadmin' ] as $boolOpt) { |
|
248 | + if (isset($options[ $boolOpt ])) { |
|
249 | + $jobSpec[ $boolOpt ] = $options[ $boolOpt ] ? 'true' : 'false'; |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - foreach (['length', 'coupon', 'pixel'] as $strOpt) { |
|
254 | - if (isset($options[$strOpt])) { |
|
255 | - $jobSpec[$strOpt] = $options[$strOpt]; |
|
253 | + foreach ([ 'length', 'coupon', 'pixel' ] as $strOpt) { |
|
254 | + if (isset($options[ $strOpt ])) { |
|
255 | + $jobSpec[ $strOpt ] = $options[ $strOpt ]; |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | 259 | $link = $job->getLink(); |
260 | - $jobSpec[':description'] = $link ? $this->getDescriptionFilter()->filter($link) : '<p></p>'; |
|
260 | + $jobSpec[ ':description' ] = $link ? $this->getDescriptionFilter()->filter($link) : '<p></p>'; |
|
261 | 261 | |
262 | 262 | if ($requirements = $job->getTemplateValues()->getRequirements()) { |
263 | - $jobSpec[':requirements'] = $requirements; |
|
263 | + $jobSpec[ ':requirements' ] = $requirements; |
|
264 | 264 | } |
265 | 265 | |
266 | - $tags = []; |
|
267 | - if (isset($options['keywords']) && is_array($options['keyword'])) { |
|
268 | - foreach ($options['keywords'] as $keyword) { |
|
269 | - $tags[] = ['tag' => $keyword]; |
|
266 | + $tags = [ ]; |
|
267 | + if (isset($options[ 'keywords' ]) && is_array($options[ 'keyword' ])) { |
|
268 | + foreach ($options[ 'keywords' ] as $keyword) { |
|
269 | + $tags[ ] = [ 'tag' => $keyword ]; |
|
270 | 270 | } |
271 | 271 | } else { |
272 | - $tags[] = ['tag' => 'none']; |
|
272 | + $tags[ ] = [ 'tag' => 'none' ]; |
|
273 | 273 | } |
274 | - $jobSpec['tags'] = $tags; |
|
274 | + $jobSpec[ 'tags' ] = $tags; |
|
275 | 275 | |
276 | - if (isset($options['advertisingregions']) && is_array($options['advertisingregions'])) { |
|
277 | - $regions = []; |
|
278 | - foreach ($options['advertisingregions'] as $adreg) { |
|
279 | - $regions[] = ['regioncode' => $adreg]; |
|
276 | + if (isset($options[ 'advertisingregions' ]) && is_array($options[ 'advertisingregions' ])) { |
|
277 | + $regions = [ ]; |
|
278 | + foreach ($options[ 'advertisingregions' ] as $adreg) { |
|
279 | + $regions[ ] = [ 'regioncode' => $adreg ]; |
|
280 | 280 | } |
281 | - $jobSpec['advertisingregions'] = $regions; |
|
281 | + $jobSpec[ 'advertisingregions' ] = $regions; |
|
282 | 282 | } |
283 | 283 | |
284 | - if (isset($options['advertisingcountries']) && is_array($options['advertisingcountries'])) { |
|
285 | - $countries = []; |
|
286 | - foreach ($options['advertisingcountries'] as $adcountry) { |
|
287 | - $countries[] = ['regioncode' => $adcountry]; |
|
284 | + if (isset($options[ 'advertisingcountries' ]) && is_array($options[ 'advertisingcountries' ])) { |
|
285 | + $countries = [ ]; |
|
286 | + foreach ($options[ 'advertisingcountries' ] as $adcountry) { |
|
287 | + $countries[ ] = [ 'regioncode' => $adcountry ]; |
|
288 | 288 | } |
289 | - $jobSpec['advertisingcountrycodes'] = $countries; |
|
289 | + $jobSpec[ 'advertisingcountrycodes' ] = $countries; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
293 | - return XmlBuilder::createXml(['job' => $jobSpec]); |
|
293 | + return XmlBuilder::createXml([ 'job' => $jobSpec ]); |
|
294 | 294 | } |
295 | 295 | } |