@@ -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 | } |