Completed
Pull Request — develop (#254)
by Carsten
07:52
created
module/Solr/src/Solr/Bridge/ResultConverter.php 2 patches
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){
107
+        if ($value instanceof \SolrObject) {
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.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
                 } elseif (method_exists($ob,$setter) && !$value instanceof \SolrObject){
68 68
                     if ($name != 'location') {
69 69
                         call_user_func(array($ob, $setter), $value);
70
-                    }elseif (!$this->useGeoLocation) {
70
+                    } elseif (!$this->useGeoLocation) {
71 71
                         call_user_func(array($ob, $setter), $value);
72 72
                     }
73
-                }elseif(isset($propertiesMap[$name])){
73
+                } elseif(isset($propertiesMap[$name])){
74 74
                     $this->handleMappedProperty($propertiesMap[$name],$ob,$value);
75 75
                 }
76 76
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         $check = $date && ($date->format(Manager::SOLR_DATE_FORMAT) === $value);
113 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.
module/Solr/src/Solr/Listener/JobEventSubscriber.php 2 patches
Spacing   +36 added lines, -36 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,37 +110,37 @@  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('entityName','job');
115
-        $document->addField('title',$job->getTitle());
116
-        $document->addField('applicationEmail',$job->getContactEmail());
113
+        $document->addField('id', $job->getId());
114
+        $document->addField('entityName', 'job');
115
+        $document->addField('title', $job->getTitle());
116
+        $document->addField('applicationEmail', $job->getContactEmail());
117 117
         if ($job->getLink()) {
118 118
             $document->addField('link', $job->getLink());
119
-            $oldErrorReporting=error_reporting(0);
119
+            $oldErrorReporting = error_reporting(0);
120 120
             $dom = new \DOMDocument();
121 121
             $dom->loadHTML($job->getLink());
122 122
             error_reporting($oldErrorReporting);
123
-            $document->addField('html',$dom->saveHTML());
123
+            $document->addField('html', $dom->saveHTML());
124 124
         }
125
-        if($job->getDateCreated()){
126
-            $document->addField('dateCreated',Util::convertDateTime($job->getDateCreated()));
125
+        if ($job->getDateCreated()) {
126
+            $document->addField('dateCreated', Util::convertDateTime($job->getDateCreated()));
127 127
         }
128
-        if($job->getDateModified()){
129
-            $document->addField('dateModified',Util::convertDateTime($job->getDateModified()));
128
+        if ($job->getDateModified()) {
129
+            $document->addField('dateModified', Util::convertDateTime($job->getDateModified()));
130 130
         }
131
-        if($job->getDatePublishStart()){
132
-            $document->addField('datePublishStart',Util::convertDateTime($job->getDatePublishStart()));
131
+        if ($job->getDatePublishStart()) {
132
+            $document->addField('datePublishStart', Util::convertDateTime($job->getDatePublishStart()));
133 133
         }
134
-        if($job->getDatePublishEnd()){
135
-            $document->addField('datePublishEnd',Util::convertDateTime($job->getDatePublishEnd()));
134
+        if ($job->getDatePublishEnd()) {
135
+            $document->addField('datePublishEnd', Util::convertDateTime($job->getDatePublishEnd()));
136 136
         }
137
-        $document->addField('isActive',$job->isActive());
138
-        $document->addField('lang',$job->getLanguage());
139
-        $this->processLocation($job,$document);
140
-        if(!is_null($job->getOrganization())){
137
+        $document->addField('isActive', $job->isActive());
138
+        $document->addField('lang', $job->getLanguage());
139
+        $this->processLocation($job, $document);
140
+        if (!is_null($job->getOrganization())) {
141 141
             try {
142
-                $this->processOrganization($job,$document);
143
-            }catch (\Exception $e){
142
+                $this->processOrganization($job, $document);
143
+            } catch (\Exception $e) {
144 144
                 // @TODO: What to do when the process failed?
145 145
             }
146 146
         }
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
      * @param Job                   $job
153 153
      * @param \SolrInputDocument    $document
154 154
      */
155
-    public function processOrganization(Job $job,$document)
155
+    public function processOrganization(Job $job, $document)
156 156
     {
157
-        if(!is_null($job->getOrganization()->getImage())){
157
+        if (!is_null($job->getOrganization()->getImage())) {
158 158
             $uri = $job->getOrganization()->getImage()->getUri();
159
-            $document->addField('companyLogo',$uri);
159
+            $document->addField('companyLogo', $uri);
160 160
         }
161
-        $document->addField('organizationName',$job->getOrganization()->getOrganizationName()->getName());
162
-        $document->addField('organizationId',$job->getOrganization()->getId());
161
+        $document->addField('organizationName', $job->getOrganization()->getOrganizationName()->getName());
162
+        $document->addField('organizationId', $job->getOrganization()->getId());
163 163
     }
164 164
 
165 165
     /**
@@ -167,30 +167,30 @@  discard block
 block discarded – undo
167 167
      * @param Job                $job
168 168
      * @param \SolrInputDocument $document
169 169
      */
170
-    public function processLocation(Job $job,$document)
170
+    public function processLocation(Job $job, $document)
171 171
     {
172 172
         /* @var \Jobs\Entity\Location $location */
173
-        $locations=$job->getLocations();
174
-        foreach($locations as $location){
173
+        $locations = $job->getLocations();
174
+        foreach ($locations as $location) {
175 175
 
176 176
             $loc = new \SolrInputDocument();
177 177
             $loc->addField('entityName', 'location');
178
-            if(is_object($location->getCoordinates())){
178
+            if (is_object($location->getCoordinates())) {
179 179
                 $coordinate = Util::convertLocationCoordinates($location);
180 180
                 $loc->addField('point', $coordinate);
181 181
                 $loc->addField('latLon', $coordinate);
182 182
                 $document->addField('locations', $coordinate);
183 183
                 $document->addField('points', $coordinate);
184
-                $loc->addField('id', $job->getId() . '-' . $coordinate);
184
+                $loc->addField('id', $job->getId().'-'.$coordinate);
185 185
                 $loc->addField('city', $location->getCity());
186 186
                 $loc->addField('country', $location->getCountry());
187 187
                 $loc->addField('region', $location->getRegion());
188 188
                 $loc->addField('postalCode', $location->getPostalCode());
189
-                $document->addField('regionList',$location->getRegion());
189
+                $document->addField('regionList', $location->getRegion());
190 190
                 $document->addChildDocument($loc);
191 191
             }
192 192
             unset($loc);
193 193
         }
194
-        $document->addField('location',$job->getLocation());
194
+        $document->addField('location', $job->getLocation());
195 195
     }
196 196
 }
197 197
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         $solrDoc = $this->generateInputDocument($document, new \SolrInputDocument());
98 98
         try{
99 99
             $this->solrManager->addDocument($solrDoc,$this->solrManager->getOptions()->getJobsPath());
100
-        }catch (\Exception $e){
100
+        } catch (\Exception $e){
101 101
             // @TODO: What to do when the process failed?
102 102
         }
103 103
     }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         if(!is_null($job->getOrganization())){
141 141
             try {
142 142
                 $this->processOrganization($job,$document);
143
-            }catch (\Exception $e){
143
+            } catch (\Exception $e){
144 144
                 // @TODO: What to do when the process failed?
145 145
             }
146 146
         }
Please login to merge, or discard this patch.
module/Solr/src/Solr/Filter/JobBoardPaginationQuery.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
                     )); // join
87 87
 
88 88
                 $query->addField('locations:[subquery]')
89
-                      ->addField('distance:min(geodist(points,'.$coordinate.'))');
89
+                        ->addField('distance:min(geodist(points,'.$coordinate.'))');
90 90
 
91 91
             }
92 92
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function createQuery(array $params, $query)
48 48
     {
49
-        $search = isset($params['search']) ? $params['search']:'';
49
+        $search = isset($params['search']) ? $params['search'] : '';
50 50
 
51
-        if(!empty($search)){
51
+        if (!empty($search)) {
52 52
             $q = \SolrUtils::escapeQueryChars($search);
53
-        }else{
53
+        } else {
54 54
             $q = '*:*';
55 55
         }
56 56
 
@@ -58,17 +58,17 @@  discard block
 block discarded – undo
58 58
         $query->addFilterQuery('entityName:job');
59 59
         $query->addField('*');
60 60
         
61
-        if(isset($params['sort'])){
61
+        if (isset($params['sort'])) {
62 62
             $sorts = $this->filterSort($params['sort']);
63
-            foreach($sorts as $field=>$order){
64
-                $query->addSortField($field,$order);
63
+            foreach ($sorts as $field=>$order) {
64
+                $query->addSortField($field, $order);
65 65
             }
66 66
         }
67 67
 
68
-        if(isset($params['location'])){
68
+        if (isset($params['location'])) {
69 69
             /* @var Location $location */
70 70
             $location = $params['location'];
71
-            if(is_object($location->getCoordinates())){
71
+            if (is_object($location->getCoordinates())) {
72 72
                 $coordinate = Util::convertLocationCoordinates($location);
73 73
 
74 74
                 $query->addFilterQuery(
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
      * @param Job       $ob
115 115
      * @param string    $value
116 116
      */
117
-    public function convertOrganizationName($ob,$value)
117
+    public function convertOrganizationName($ob, $value)
118 118
     {
119
-        if(!is_object($ob->getOrganization())){
119
+        if (!is_object($ob->getOrganization())) {
120 120
             $ob->setOrganization(new Organization());
121 121
         }
122 122
         $orgName = new OrganizationName($value);
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
      * @param   Job     $ob
129 129
      * @param   mixed   $value
130 130
      */
131
-    public function convertCompanyLogo($ob,$value)
131
+    public function convertCompanyLogo($ob, $value)
132 132
     {
133
-        if(!is_object($ob->getOrganization())){
133
+        if (!is_object($ob->getOrganization())) {
134 134
             $ob->setOrganization(new Organization());
135 135
         }
136
-        $exp    = explode('/',$value);
136
+        $exp    = explode('/', $value);
137 137
         $id     = $exp[3];
138
-        $name   = isset($exp[4])?:null;
138
+        $name   = isset($exp[4]) ?: null;
139 139
         $image = new OrganizationImage();
140 140
         $image->setId($id);
141 141
         $image->setName($name);
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
      * @param   Job     $ob
148 148
      * @param   mixed   $value
149 149
      */
150
-    public function convertLocations($ob,$value)
150
+    public function convertLocations($ob, $value)
151 151
     {
152 152
         $locations = [];
153
-        foreach($value->docs as $doc) {
153
+        foreach ($value->docs as $doc) {
154 154
             $locations[] = $doc->city;
155 155
         }
156 156
         $ob->setLocation(implode(', ', array_unique($locations)));
Please login to merge, or discard this patch.
module/Solr/src/Solr/Paginator/Adapter/SolrAdapter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param   ResultConverter             $resultConverter
71 71
      * @param   array                       $params
72 72
      */
73
-    public function __construct($client,$filter,$resultConverter,$params=array())
73
+    public function __construct($client, $filter, $resultConverter, $params = array())
74 74
     {
75 75
         $this->client           = $client;
76 76
         $this->filter           = $filter;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         return $this->resultConverter->convert(
87 87
             $this->filter,
88
-            $this->getResponse($offset,$itemCountPerPage)
88
+            $this->getResponse($offset, $itemCountPerPage)
89 89
         );
90 90
     }
91 91
 
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
      * @return  \SolrQueryResponse
109 109
      * @throws  \Exception
110 110
      */
111
-    protected function getResponse($offset=0,$itemCountPerPage=0)
111
+    protected function getResponse($offset = 0, $itemCountPerPage = 0)
112 112
     {
113 113
         $id = md5($offset.$itemCountPerPage);
114
-        if(!isset($this->responses[$id])){
114
+        if (!isset($this->responses[$id])) {
115 115
             $query = new \SolrQuery();
116
-            $query = $this->filter->filter($this->params,$query);
116
+            $query = $this->filter->filter($this->params, $query);
117 117
             $query->setStart($offset);
118 118
             $query->setRows($itemCountPerPage);
119
-            try{
119
+            try {
120 120
                 $this->responses[$id] = $this->client->query($query);
121
-            }catch (\Exception $e){
121
+            } catch (\Exception $e) {
122 122
                 $message = 'Failed to process query';
123
-                throw new ServerException($message,$e->getCode(),$e);
123
+                throw new ServerException($message, $e->getCode(), $e);
124 124
             }
125 125
         }
126 126
 
Please login to merge, or discard this patch.