Completed
Pull Request — develop (#250)
by ANTHONIUS
08:15
created
module/Solr/src/Solr/Filter/JobBoardPaginationQuery.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -43,30 +43,30 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function createQuery(array $params, $query)
45 45
     {
46
-        $search = isset($params['search']) ? $params['search']:'';
46
+        $search = isset($params['search']) ? $params['search'] : '';
47 47
 
48
-        if(!empty($search)){
48
+        if (!empty($search)) {
49 49
             $q = 'title:'.$search.' OR organizationName:'.$search;
50
-        }else{
50
+        } else {
51 51
             $q = '*:*';
52 52
         }
53 53
 
54 54
         $query->setQuery($q);
55 55
         
56
-        if(isset($params['sort'])){
56
+        if (isset($params['sort'])) {
57 57
             $sorts = $this->filterSort($params['sort']);
58
-            foreach($sorts as $field=>$order){
59
-                $query->addSortField($field,$order);
58
+            foreach ($sorts as $field=>$order) {
59
+                $query->addSortField($field, $order);
60 60
             }
61 61
         }
62 62
 
63
-        if(isset($params['location'])){
63
+        if (isset($params['location'])) {
64 64
             /* @var Location $location */
65 65
             $location = $params['location'];
66
-            if(!is_null($location->getCoordinates())){
66
+            if (!is_null($location->getCoordinates())) {
67 67
                 $coordinates = $location->getCoordinates()->getCoordinates();
68 68
                 $coordinate = doubleval($coordinates[0]).'%'.doubleval($coordinates[1]);
69
-                $coordinate = strtr($coordinate,['%'=>',',','=>'.']);
69
+                $coordinate = strtr($coordinate, ['%'=>',', ','=>'.']);
70 70
                 
71 71
                 $query->addFilterQuery(sprintf(
72 72
                     "{!geofilt pt=%s sfield=latLon d=%s}",
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
      * @param Job       $ob
93 93
      * @param string    $value
94 94
      */
95
-    public function convertOrganizationName($ob,$value)
95
+    public function convertOrganizationName($ob, $value)
96 96
     {
97
-        if(!is_object($ob->getOrganization())){
97
+        if (!is_object($ob->getOrganization())) {
98 98
             $ob->setOrganization(new Organization());
99 99
         }
100 100
         $orgName = new OrganizationName($value);
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
      * @param   Job     $ob
107 107
      * @param   mixed   $value
108 108
      */
109
-    public function convertCompanyLogo($ob,$value)
109
+    public function convertCompanyLogo($ob, $value)
110 110
     {
111
-        if(!is_object($ob->getOrganization())){
111
+        if (!is_object($ob->getOrganization())) {
112 112
             $ob->setOrganization(new Organization());
113 113
         }
114
-        $exp    = explode('/',$value);
114
+        $exp    = explode('/', $value);
115 115
         $id     = $exp[3];
116 116
         $name   = $exp[4];
117 117
         $image = new OrganizationImage();
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=5)
111
+    protected function getResponse($offset = 0, $itemCountPerPage = 5)
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.
module/Solr/src/Solr/Listener/JobEventSubscriber.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
      */
91 91
     protected function updateIndex($document)
92 92
     {
93
-        if(!$document instanceof Job){
93
+        if (!$document instanceof Job) {
94 94
             return;
95 95
         }
96 96
         $solrDoc = $this->generateInputDocument($document, new \SolrInputDocument());
97
-        try{
98
-            $this->solrManager->addDocument($solrDoc,$this->solrManager->getOptions()->getJobsPath());
99
-        }catch (\Exception $e){
97
+        try {
98
+            $this->solrManager->addDocument($solrDoc, $this->solrManager->getOptions()->getJobsPath());
99
+        } catch (\Exception $e) {
100 100
             // @TODO: What to do when the process failed?
101 101
         }
102 102
     }
@@ -109,34 +109,34 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function generateInputDocument(Job $job, $document)
111 111
     {
112
-        $document->addField('id',$job->getId());
113
-        $document->addField('title',$job->getTitle());
114
-        $document->addField('applicationEmail',$job->getContactEmail());
115
-        if($job->getDateCreated()){
112
+        $document->addField('id', $job->getId());
113
+        $document->addField('title', $job->getTitle());
114
+        $document->addField('applicationEmail', $job->getContactEmail());
115
+        if ($job->getDateCreated()) {
116 116
             $document->addField('dateCreated',
117 117
                 $job->getDateCreated()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
118 118
             );
119 119
         }
120
-        if($job->getDateModified()){
120
+        if ($job->getDateModified()) {
121 121
             $document->addField('dateModified',
122 122
                 $job->getDateModified()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
123 123
             );
124 124
         }
125
-        if($job->getDatePublishStart()){
125
+        if ($job->getDatePublishStart()) {
126 126
             $document->addField('datePublishStart',
127 127
                 $job->getDatePublishStart()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
128 128
             );
129 129
         }
130
-        if($job->getDatePublishEnd()){
130
+        if ($job->getDatePublishEnd()) {
131 131
             $document->addField('datePublishEnd',
132 132
                 $job->getDatePublishEnd()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
133 133
             );
134 134
         }
135
-        $document->addField('isActive',$job->isActive());
136
-        $document->addField('lang',$job->getLanguage());
137
-        $this->processLocation($job,$document);
138
-        if(!is_null($job->getOrganization())){
139
-            $this->processOrganization($job,$document);
135
+        $document->addField('isActive', $job->isActive());
136
+        $document->addField('lang', $job->getLanguage());
137
+        $this->processLocation($job, $document);
138
+        if (!is_null($job->getOrganization())) {
139
+            $this->processOrganization($job, $document);
140 140
         }
141 141
         return $document;
142 142
     }
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
      * @param Job                   $job
147 147
      * @param \SolrInputDocument    $document
148 148
      */
149
-    public function processOrganization(Job $job,$document)
149
+    public function processOrganization(Job $job, $document)
150 150
     {
151
-        if(!is_null($job->getOrganization()->getImage())){
151
+        if (!is_null($job->getOrganization()->getImage())) {
152 152
             $uri = $job->getOrganization()->getImage()->getUri();
153
-            $document->addField('companyLogo',$uri);
153
+            $document->addField('companyLogo', $uri);
154 154
         }
155
-        $document->addField('organizationName',$job->getOrganization()->getOrganizationName()->getName());
156
-        $document->addField('organizationId',$job->getOrganization()->getId());
155
+        $document->addField('organizationName', $job->getOrganization()->getOrganizationName()->getName());
156
+        $document->addField('organizationId', $job->getOrganization()->getId());
157 157
     }
158 158
 
159 159
     /**
@@ -161,23 +161,23 @@  discard block
 block discarded – undo
161 161
      * @param Job                $job
162 162
      * @param \SolrInputDocument $document
163 163
      */
164
-    public function processLocation(Job $job,$document)
164
+    public function processLocation(Job $job, $document)
165 165
     {
166 166
         /* @var \Jobs\Entity\Location $location */
167
-        foreach($job->getLocations() as $location){
168
-            if(is_object($location->getCoordinates())){
167
+        foreach ($job->getLocations() as $location) {
168
+            if (is_object($location->getCoordinates())) {
169 169
                 $coordinates = $location->getCoordinates()->getCoordinates();
170 170
                 $coordinate = doubleval($coordinates[0]).'%'.doubleval($coordinates[1]);
171
-                $coordinate = strtr($coordinate,[
171
+                $coordinate = strtr($coordinate, [
172 172
                     '%'=>',',
173 173
                     ','=>'.'
174 174
                 ]);
175
-                $document->addField('latLon',$coordinate);
175
+                $document->addField('latLon', $coordinate);
176 176
             }
177
-            $document->addField('postCode',$location->getPostalCode());
178
-            $document->addField('regionText',$location->getRegion());
177
+            $document->addField('postCode', $location->getPostalCode());
178
+            $document->addField('regionText', $location->getRegion());
179 179
         }
180 180
 
181
-        $document->addField('location',$job->getLocation());
181
+        $document->addField('location', $job->getLocation());
182 182
     }
183 183
 }
184 184
\ No newline at end of file
Please login to merge, or discard this patch.