Completed
Push — develop ( 6f84da...725207 )
by
unknown
15:39 queued 08:13
created
module/Solr/src/Solr/Listener/JobEventSubscriber.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function updateIndex($document)
93 93
     {
94
-        if(!$document instanceof Job){
94
+        if (!$document instanceof Job) {
95 95
             return;
96 96
         }
97 97
         $solrDoc = $this->generateInputDocument($document, new \SolrInputDocument());
98
-        try{
99
-            $this->solrManager->addDocument($solrDoc,$this->solrManager->getOptions()->getJobsPath());
100
-        }catch (\Exception $e){
98
+        try {
99
+            $this->solrManager->addDocument($solrDoc, $this->solrManager->getOptions()->getJobsPath());
100
+        } catch (\Exception $e) {
101 101
             // @TODO: What to do when the process failed?
102 102
         }
103 103
     }
@@ -110,41 +110,41 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function generateInputDocument(Job $job, $document)
112 112
     {
113
-        $document->addField('id',$job->getId());
114
-        $document->addField('applyId',$job->getApplyId());
115
-        $document->addField('entityName','job');
116
-        $document->addField('title',$job->getTitle());
117
-        $document->addField('applicationEmail',$job->getContactEmail());
113
+        $document->addField('id', $job->getId());
114
+        $document->addField('applyId', $job->getApplyId());
115
+        $document->addField('entityName', 'job');
116
+        $document->addField('title', $job->getTitle());
117
+        $document->addField('applicationEmail', $job->getContactEmail());
118 118
         if ($job->getLink()) {
119 119
             $document->addField('link', $job->getLink());
120
-            $oldErrorReporting=error_reporting(0);
120
+            $oldErrorReporting = error_reporting(0);
121 121
             $dom = new \DOMDocument();
122 122
             // @TODO: 
123 123
             // we temporary put the html into the index. This will be removed later. For now it's the easiest way to get
124 124
             // some searchable content
125 125
             $dom->loadHTMLFile($job->getLink());
126 126
             error_reporting($oldErrorReporting);
127
-            $document->addField('html',$dom->saveHTML());
127
+            $document->addField('html', $dom->saveHTML());
128 128
         }
129
-        if($job->getDateCreated()){
130
-            $document->addField('dateCreated',Util::convertDateTime($job->getDateCreated()));
129
+        if ($job->getDateCreated()) {
130
+            $document->addField('dateCreated', Util::convertDateTime($job->getDateCreated()));
131 131
         }
132
-        if($job->getDateModified()){
133
-            $document->addField('dateModified',Util::convertDateTime($job->getDateModified()));
132
+        if ($job->getDateModified()) {
133
+            $document->addField('dateModified', Util::convertDateTime($job->getDateModified()));
134 134
         }
135
-        if($job->getDatePublishStart()){
136
-            $document->addField('datePublishStart',Util::convertDateTime($job->getDatePublishStart()));
135
+        if ($job->getDatePublishStart()) {
136
+            $document->addField('datePublishStart', Util::convertDateTime($job->getDatePublishStart()));
137 137
         }
138
-        if($job->getDatePublishEnd()){
139
-            $document->addField('datePublishEnd',Util::convertDateTime($job->getDatePublishEnd()));
138
+        if ($job->getDatePublishEnd()) {
139
+            $document->addField('datePublishEnd', Util::convertDateTime($job->getDatePublishEnd()));
140 140
         }
141
-        $document->addField('isActive',$job->isActive());
142
-        $document->addField('lang',$job->getLanguage());
143
-        $this->processLocation($job,$document);
144
-        if(!is_null($job->getOrganization())){
141
+        $document->addField('isActive', $job->isActive());
142
+        $document->addField('lang', $job->getLanguage());
143
+        $this->processLocation($job, $document);
144
+        if (!is_null($job->getOrganization())) {
145 145
             try {
146
-                $this->processOrganization($job,$document);
147
-            }catch (\Exception $e){
146
+                $this->processOrganization($job, $document);
147
+            } catch (\Exception $e) {
148 148
                 // @TODO: What to do when the process failed?
149 149
             }
150 150
         }
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
      * @param Job                   $job
158 158
      * @param \SolrInputDocument    $document
159 159
      */
160
-    public function processOrganization(Job $job,$document)
160
+    public function processOrganization(Job $job, $document)
161 161
     {
162
-        if(!is_null($job->getOrganization()->getImage())){
162
+        if (!is_null($job->getOrganization()->getImage())) {
163 163
             $uri = $job->getOrganization()->getImage()->getUri();
164
-            $document->addField('companyLogo',$uri);
164
+            $document->addField('companyLogo', $uri);
165 165
         }
166
-        $document->addField('organizationName',$job->getOrganization()->getOrganizationName()->getName());
167
-        $document->addField('organizationId',$job->getOrganization()->getId());
166
+        $document->addField('organizationName', $job->getOrganization()->getOrganizationName()->getName());
167
+        $document->addField('organizationId', $job->getOrganization()->getId());
168 168
     }
169 169
 
170 170
     /**
@@ -172,30 +172,30 @@  discard block
 block discarded – undo
172 172
      * @param Job                $job
173 173
      * @param \SolrInputDocument $document
174 174
      */
175
-    public function processLocation(Job $job,$document)
175
+    public function processLocation(Job $job, $document)
176 176
     {
177 177
         /* @var \Jobs\Entity\Location $location */
178
-        $locations=$job->getLocations();
179
-        foreach($locations as $location){
178
+        $locations = $job->getLocations();
179
+        foreach ($locations as $location) {
180 180
 
181 181
             $loc = new \SolrInputDocument();
182 182
             $loc->addField('entityName', 'location');
183
-            if(is_object($location->getCoordinates())){
183
+            if (is_object($location->getCoordinates())) {
184 184
                 $coordinate = Util::convertLocationCoordinates($location);
185 185
                 $loc->addField('point', $coordinate);
186 186
                 $loc->addField('latLon', $coordinate);
187 187
                 $document->addField('locations', $coordinate);
188 188
                 $document->addField('points', $coordinate);
189
-                $loc->addField('id', $job->getId() . '-' . $coordinate);
189
+                $loc->addField('id', $job->getId().'-'.$coordinate);
190 190
                 $loc->addField('city', $location->getCity());
191 191
                 $loc->addField('country', $location->getCountry());
192 192
                 $loc->addField('region', $location->getRegion());
193 193
                 $loc->addField('postalCode', $location->getPostalCode());
194
-                $document->addField('regionList',$location->getRegion());
194
+                $document->addField('regionList', $location->getRegion());
195 195
                 $document->addChildDocument($loc);
196 196
             }
197 197
             unset($loc);
198 198
         }
199
-        $document->addField('location',$job->getLocation());
199
+        $document->addField('location', $job->getLocation());
200 200
     }
201 201
 }
202 202
\ No newline at end of file
Please login to merge, or discard this patch.
module/Solr/src/Solr/Bridge/ResultConverter.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @var bool
38 38
      */
39
-    protected $useGeoLocation=false;
39
+    protected $useGeoLocation = false;
40 40
 
41 41
     /**
42 42
      * Convert result into entity
@@ -52,26 +52,26 @@  discard block
 block discarded – undo
52 52
         $propertiesMap = $filter->getPropertiesMap();
53 53
         $class = $filter->getEntityClass();
54 54
         $entities = [];
55
-        foreach($response['response']['docs'] as $doc){
55
+        foreach ($response['response']['docs'] as $doc) {
56 56
             $ob = new $class();
57 57
             $properties = $doc->getPropertyNames();
58
-            foreach($properties as $name){
58
+            foreach ($properties as $name) {
59 59
                 $setter = 'set'.$name;
60 60
                 $value = $doc->$name;
61 61
                 $value = $this->validateDate($value);
62 62
                 if ($value instanceof \SolrObject) {
63 63
                     if ($name == 'locations') {
64
-                        $this->useGeoLocation=true;
64
+                        $this->useGeoLocation = true;
65 65
                     }
66
-                    $this->handleMappedProperty($propertiesMap[$name],$ob,$value);
67
-                } elseif (method_exists($ob,$setter) && !$value instanceof \SolrObject){
66
+                    $this->handleMappedProperty($propertiesMap[$name], $ob, $value);
67
+                } elseif (method_exists($ob, $setter) && !$value instanceof \SolrObject) {
68 68
                     if ($name != 'location') {
69 69
                         call_user_func(array($ob, $setter), $value);
70 70
                     }elseif (!$this->useGeoLocation) {
71 71
                         call_user_func(array($ob, $setter), $value);
72 72
                     }
73
-                }elseif(isset($propertiesMap[$name])){
74
-                    $this->handleMappedProperty($propertiesMap[$name],$ob,$value);
73
+                }elseif (isset($propertiesMap[$name])) {
74
+                    $this->handleMappedProperty($propertiesMap[$name], $ob, $value);
75 75
                 }
76 76
 
77 77
             }
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
      * @param $object
89 89
      * @param $value
90 90
      */
91
-    public function handleMappedProperty($property,$object,$value)
91
+    public function handleMappedProperty($property, $object, $value)
92 92
     {
93
-        $callback = array($this->filter,$property);
94
-        if(is_callable($callback)){
95
-            call_user_func($callback,$object,$value);
93
+        $callback = array($this->filter, $property);
94
+        if (is_callable($callback)) {
95
+            call_user_func($callback, $object, $value);
96 96
         }
97 97
     }
98 98
 
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function validateDate($value)
106 106
     {
107
-        if ($value instanceof \SolrObject || is_array($value)){
107
+        if ($value instanceof \SolrObject || is_array($value)) {
108 108
             return $value;
109 109
         }
110 110
         $value = trim($value);
111
-        $date = \DateTime::createFromFormat(Manager::SOLR_DATE_FORMAT,$value);
111
+        $date = \DateTime::createFromFormat(Manager::SOLR_DATE_FORMAT, $value);
112 112
         $check = $date && ($date->format(Manager::SOLR_DATE_FORMAT) === $value);
113
-        if($check){
113
+        if ($check) {
114 114
             return $date;
115
-        }else{
115
+        } else {
116 116
             return $value;
117 117
         }
118 118
     }
Please login to merge, or discard this patch.