Completed
Pull Request — develop (#259)
by ANTHONIUS
09:01
created
module/Solr/src/Solr/Paginator/PaginatorFactoryAbstract.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 
25 25
     /**
26 26
      * @param ServiceLocatorInterface $serviceLocator
27
-     * @return mixed|Paginator
27
+     * @return Paginator
28 28
      */
29 29
     public function createService(ServiceLocatorInterface $serviceLocator)
30 30
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use Zend\ServiceManager\MutableCreationOptionsInterface;
16 16
 use Zend\ServiceManager\ServiceLocatorInterface;
17 17
 
18
-abstract class PaginatorFactoryAbstract implements FactoryInterface,MutableCreationOptionsInterface
18
+abstract class PaginatorFactoryAbstract implements FactoryInterface, MutableCreationOptionsInterface
19 19
 {
20 20
     protected $options = [];
21 21
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $connectPath        = $this->getConnectPath();
48 48
         $solrClient         = $serviceLocator->getServiceLocator()->get('Solr/Manager')->getClient($connectPath);
49 49
         $resultConverter    = $serviceLocator->getServiceLocator()->get('Solr/ResultConverter');
50
-        $adapter            = new SolrAdapter($solrClient,$filter,$resultConverter,$this->options);
50
+        $adapter            = new SolrAdapter($solrClient, $filter, $resultConverter, $this->options);
51 51
         $service            = new Paginator($adapter);
52 52
 
53 53
         $this->setCreationOptions([]);
Please login to merge, or discard this patch.
module/Solr/src/Solr/Bridge/Manager.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         $this->connectOption = $connectOption;
30 30
     }
31 31
 
32
-    public function getClient($path='/solr')
32
+    public function getClient($path = '/solr')
33 33
     {
34 34
         $connectOption = $this->connectOption;
35 35
         $options = [
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
      * @param \SolrInputDocument $document
49 49
      * @param string $path
50 50
      */
51
-    public function addDocument(\SolrInputDocument $document,$path='/solr')
51
+    public function addDocument(\SolrInputDocument $document, $path = '/solr')
52 52
     {
53 53
         $client = $this->getClient($path);
54
-        try{
54
+        try {
55 55
             $client->addDocument($document);
56 56
             $client->commit();
57 57
             $client->optimize();
58
-        }catch (\Exception $e){
59
-            throw new ServerException('Can not add document to server!',$e->getCode(),$e);
58
+        } catch (\Exception $e) {
59
+            throw new ServerException('Can not add document to server!', $e->getCode(), $e);
60 60
         }
61 61
     }
62 62
     
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
             $client->addDocument($document);
56 56
             $client->commit();
57 57
             $client->optimize();
58
-        }catch (\Exception $e){
58
+        } catch (\Exception $e){
59 59
             throw new ServerException('Can not add document to server!',$e->getCode(),$e);
60 60
         }
61 61
     }
Please login to merge, or discard this patch.
module/Solr/src/Solr/Paginator/Adapter/SolrAdapter.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
             $query->setRows($itemCountPerPage);
109 109
             try{
110 110
                 $this->response = $this->client->query($query);
111
-            }catch (\Exception $e){
111
+            } catch (\Exception $e){
112 112
                 $message = 'Failed to process query';
113 113
                 throw new ServerException($message,$e->getCode(),$e);
114 114
             }
Please login to merge, or discard this 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.
module/Solr/src/Solr/Filter/JobBoardPaginationQuery.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
             if ($this->value['params']['status'] != 'all'){
63 63
                 $queryBuilder->field('status.name')->equals($this->value['params']['status']);
64 64
             }
65
-        }else{
65
+        } else{
66 66
             $queryBuilder->field('status.name')->equals(Status::CREATED);
67 67
         }
68 68
 
Please login to merge, or discard this patch.
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   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function createQuery(array $params, $query)
42 42
     {
43
-        $search = isset($params['search']) ? $params['search']:'';
43
+        $search = isset($params['search']) ? $params['search'] : '';
44 44
 
45
-        if(!empty($search)){
45
+        if (!empty($search)) {
46 46
             $q = \SolrUtils::escapeQueryChars($search);
47
-        }else{
47
+        } else {
48 48
             $q = '*:*';
49 49
         }
50 50
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
         $query->addFilterQuery('isActive:1');
54 54
         $query->addField('*');
55 55
         
56
-        if(isset($params['location'])){
56
+        if (isset($params['location'])) {
57 57
             /* @var Location $location */
58 58
             $location = $params['location'];
59
-            if(is_object($location->getCoordinates())){
59
+            if (is_object($location->getCoordinates())) {
60 60
                 $coordinate = Util::convertLocationCoordinates($location);
61 61
 
62 62
                 $query->addFilterQuery(
Please login to merge, or discard this patch.
module/Solr/src/Solr/Filter/AbstractPaginationQuery.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $query = new \SolrQuery();
46 46
         
47
-        return $this->createQuery($value,$query);
47
+        return $this->createQuery($value, $query);
48 48
     }
49 49
 
50 50
     /**
@@ -101,5 +101,5 @@  discard block
 block discarded – undo
101 101
      * @param   \SolrQuery $query
102 102
      * @return  \SolrQuery
103 103
      */
104
-    abstract public function createQuery(array $params,$query);
104
+    abstract public function createQuery(array $params, $query);
105 105
 }
106 106
\ No newline at end of file
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,8 @@
 block discarded – undo
55 55
     /**
56 56
      * Filter query based on given value
57 57
      *
58
-     * @param mixed $value
59
-     * @return \SolrDisMaxQuery
58
+     * @param \Zend\Stdlib\Parameters $value
59
+     * @return \SolrParams
60 60
      */
61 61
     public function filter($value)
62 62
     {
Please login to merge, or discard this patch.
module/Solr/src/Solr/Listener/JobEventSubscriber.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
 
75 75
     /**
76 76
      * @param ServiceLocatorInterface $serviceLocator
77
-     * @return mixed
77
+     * @return JobEventSubscriber
78 78
      */
79 79
     static public function factory(ServiceLocatorInterface $serviceLocator)
80 80
     {
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.
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/Module.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
         return array(
41 41
             'Zend\Loader\StandardAutoloader' => array(
42 42
                 'namespaces' => array(
43
-                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
43
+                    __NAMESPACE__ => __DIR__.'/src/'.__NAMESPACE__,
44 44
                 ),
45 45
             ),
46 46
         );
Please login to merge, or discard this patch.
module/Solr/src/Solr/Listener/CreatePaginatorListener.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@
 block discarded – undo
31 31
         $paginatorName = $event->getPaginatorName();
32 32
         $paginators = $event->getPaginators();
33 33
         $serviceName = 'Solr/'.$paginatorName;
34
-        if($paginators->has($serviceName)){
34
+        if ($paginators->has($serviceName)) {
35 35
             /* @var \Zend\Paginator\Paginator $paginator */
36 36
             // yes, we have that solr paginator to replace $paginatorName
37
-            $paginator = $paginators->get($serviceName,$params);
37
+            $paginator = $paginators->get($serviceName, $params);
38 38
             $event->setPaginator($paginator);
39 39
         }
40 40
     }
Please login to merge, or discard this patch.
module/Solr/config/module.config.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
         'Core/CreatePaginator/Events' => [
27 27
             'listeners' => [
28 28
                 'Solr/Listener/CreatePaginator' => [
29
-                    \Core\Listener\Events\CreatePaginatorEvent::EVENT_CREATE_PAGINATOR,'onCreatePaginator',1
29
+                    \Core\Listener\Events\CreatePaginatorEvent::EVENT_CREATE_PAGINATOR, 'onCreatePaginator', 1
30 30
                 ]
31 31
             ]
32 32
         ]
Please login to merge, or discard this patch.