@@ -92,13 +92,13 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | protected function updateIndex($document) |
| 94 | 94 | { |
| 95 | - if(!$document instanceof Job){ |
|
| 95 | + if (!$document instanceof Job) { |
|
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | $solrDoc = $this->generateInputDocument($document, new \SolrInputDocument()); |
| 99 | - try{ |
|
| 100 | - $this->solrManager->addDocument($solrDoc,$this->solrManager->getOptions()->getJobsPath()); |
|
| 101 | - }catch (\Exception $e){ |
|
| 99 | + try { |
|
| 100 | + $this->solrManager->addDocument($solrDoc, $this->solrManager->getOptions()->getJobsPath()); |
|
| 101 | + } catch (\Exception $e) { |
|
| 102 | 102 | // @TODO: What to do when the process failed? |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -111,33 +111,33 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function generateInputDocument(Job $job, $document) |
| 113 | 113 | { |
| 114 | - $document->addField('id',$job->getId()); |
|
| 115 | - $document->addField('applyId',$job->getApplyId()); |
|
| 116 | - $document->addField('entityName','job'); |
|
| 117 | - $document->addField('title',$job->getTitle()); |
|
| 118 | - $document->addField('applicationEmail',$job->getContactEmail()); |
|
| 114 | + $document->addField('id', $job->getId()); |
|
| 115 | + $document->addField('applyId', $job->getApplyId()); |
|
| 116 | + $document->addField('entityName', 'job'); |
|
| 117 | + $document->addField('title', $job->getTitle()); |
|
| 118 | + $document->addField('applicationEmail', $job->getContactEmail()); |
|
| 119 | 119 | if ($job->getLink()) { |
| 120 | 120 | $document->addField('link', $job->getLink()); |
| 121 | 121 | } |
| 122 | - if($job->getDateCreated()){ |
|
| 123 | - $document->addField('dateCreated',Util::convertDateTime($job->getDateCreated())); |
|
| 122 | + if ($job->getDateCreated()) { |
|
| 123 | + $document->addField('dateCreated', Util::convertDateTime($job->getDateCreated())); |
|
| 124 | 124 | } |
| 125 | - if($job->getDateModified()){ |
|
| 126 | - $document->addField('dateModified',Util::convertDateTime($job->getDateModified())); |
|
| 125 | + if ($job->getDateModified()) { |
|
| 126 | + $document->addField('dateModified', Util::convertDateTime($job->getDateModified())); |
|
| 127 | 127 | } |
| 128 | - if($job->getDatePublishStart()){ |
|
| 129 | - $document->addField('datePublishStart',Util::convertDateTime($job->getDatePublishStart())); |
|
| 128 | + if ($job->getDatePublishStart()) { |
|
| 129 | + $document->addField('datePublishStart', Util::convertDateTime($job->getDatePublishStart())); |
|
| 130 | 130 | } |
| 131 | - if($job->getDatePublishEnd()){ |
|
| 132 | - $document->addField('datePublishEnd',Util::convertDateTime($job->getDatePublishEnd())); |
|
| 131 | + if ($job->getDatePublishEnd()) { |
|
| 132 | + $document->addField('datePublishEnd', Util::convertDateTime($job->getDatePublishEnd())); |
|
| 133 | 133 | } |
| 134 | - $document->addField('isActive',$job->isActive()); |
|
| 135 | - $document->addField('lang',$job->getLanguage()); |
|
| 136 | - $this->processLocation($job,$document); |
|
| 137 | - if(!is_null($job->getOrganization())){ |
|
| 134 | + $document->addField('isActive', $job->isActive()); |
|
| 135 | + $document->addField('lang', $job->getLanguage()); |
|
| 136 | + $this->processLocation($job, $document); |
|
| 137 | + if (!is_null($job->getOrganization())) { |
|
| 138 | 138 | try { |
| 139 | - $this->processOrganization($job,$document); |
|
| 140 | - }catch (\Exception $e){ |
|
| 139 | + $this->processOrganization($job, $document); |
|
| 140 | + } catch (\Exception $e) { |
|
| 141 | 141 | // @TODO: What to do when the process failed? |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -158,14 +158,14 @@ discard block |
||
| 158 | 158 | * @param Job $job |
| 159 | 159 | * @param \SolrInputDocument $document |
| 160 | 160 | */ |
| 161 | - public function processOrganization(Job $job,$document) |
|
| 161 | + public function processOrganization(Job $job, $document) |
|
| 162 | 162 | { |
| 163 | - if(!is_null($job->getOrganization()->getImage())){ |
|
| 163 | + if (!is_null($job->getOrganization()->getImage())) { |
|
| 164 | 164 | $uri = $job->getOrganization()->getImage()->getUri(); |
| 165 | - $document->addField('companyLogo',$uri); |
|
| 165 | + $document->addField('companyLogo', $uri); |
|
| 166 | 166 | } |
| 167 | - $document->addField('organizationName',$job->getOrganization()->getOrganizationName()->getName()); |
|
| 168 | - $document->addField('organizationId',$job->getOrganization()->getId()); |
|
| 167 | + $document->addField('organizationName', $job->getOrganization()->getOrganizationName()->getName()); |
|
| 168 | + $document->addField('organizationId', $job->getOrganization()->getId()); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -173,30 +173,30 @@ discard block |
||
| 173 | 173 | * @param Job $job |
| 174 | 174 | * @param \SolrInputDocument $document |
| 175 | 175 | */ |
| 176 | - public function processLocation(Job $job,$document) |
|
| 176 | + public function processLocation(Job $job, $document) |
|
| 177 | 177 | { |
| 178 | 178 | /* @var \Jobs\Entity\Location $location */ |
| 179 | - $locations=$job->getLocations(); |
|
| 180 | - foreach($locations as $location){ |
|
| 179 | + $locations = $job->getLocations(); |
|
| 180 | + foreach ($locations as $location) { |
|
| 181 | 181 | |
| 182 | 182 | $loc = new \SolrInputDocument(); |
| 183 | 183 | $loc->addField('entityName', 'location'); |
| 184 | - if(is_object($location->getCoordinates())){ |
|
| 184 | + if (is_object($location->getCoordinates())) { |
|
| 185 | 185 | $coordinate = Util::convertLocationCoordinates($location); |
| 186 | 186 | $loc->addField('point', $coordinate); |
| 187 | 187 | $loc->addField('latLon', $coordinate); |
| 188 | 188 | $document->addField('locations', $coordinate); |
| 189 | 189 | $document->addField('points', $coordinate); |
| 190 | - $loc->addField('id', $job->getId() . '-' . $coordinate); |
|
| 190 | + $loc->addField('id', $job->getId().'-'.$coordinate); |
|
| 191 | 191 | $loc->addField('city', $location->getCity()); |
| 192 | 192 | $loc->addField('country', $location->getCountry()); |
| 193 | 193 | $loc->addField('region', $location->getRegion()); |
| 194 | 194 | $loc->addField('postalCode', $location->getPostalCode()); |
| 195 | - $document->addField('regionList',$location->getRegion()); |
|
| 195 | + $document->addField('regionList', $location->getRegion()); |
|
| 196 | 196 | $document->addChildDocument($loc); |
| 197 | 197 | } |
| 198 | 198 | unset($loc); |
| 199 | 199 | } |
| 200 | - $document->addField('location',$job->getLocation()); |
|
| 200 | + $document->addField('location', $job->getLocation()); |
|
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | \ No newline at end of file |