Completed
Pull Request — develop (#241)
by ANTHONIUS
08:03
created
module/Solr/src/Solr/Event/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.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
         }
51 51
 
52 52
         $solrDoc = $this->generateInputDocument($document, new \SolrInputDocument());
53
-        try{
54
-            $this->solrManager->addDocument($solrDoc,'/solr/YawikJobs');
55
-        }catch (\Exception $e){
53
+        try {
54
+            $this->solrManager->addDocument($solrDoc, '/solr/YawikJobs');
55
+        } catch (\Exception $e) {
56 56
             // @TODO: What to do when the process failed?
57 57
         }
58 58
     }
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
             return;
65 65
         }
66 66
 
67
-        $solrDoc = $this->generateInputDocument($document,new \SolrInputDocument());
68
-        try{
69
-            $this->solrManager->addDocument($solrDoc,'/solr/YawikJobs');
70
-        }catch (\Exception $e){
67
+        $solrDoc = $this->generateInputDocument($document, new \SolrInputDocument());
68
+        try {
69
+            $this->solrManager->addDocument($solrDoc, '/solr/YawikJobs');
70
+        } catch (\Exception $e) {
71 71
             // @TODO: What to do when the process failed?
72 72
         }
73 73
     }
@@ -88,63 +88,63 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function generateInputDocument(Job $job, $document)
90 90
     {
91
-        $document->addField('id',$job->getId());
92
-        $document->addField('title',$job->getTitle());
93
-        $document->addField('applicationEmail',$job->getContactEmail());
91
+        $document->addField('id', $job->getId());
92
+        $document->addField('title', $job->getTitle());
93
+        $document->addField('applicationEmail', $job->getContactEmail());
94 94
 
95
-        if($job->getDateCreated()){
95
+        if ($job->getDateCreated()) {
96 96
             $document->addField('dateCreated',
97 97
                 $job->getDateCreated()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
98 98
             );
99 99
         }
100
-        if($job->getDateModified()){
100
+        if ($job->getDateModified()) {
101 101
             $document->addField('dateModified',
102 102
                 $job->getDateModified()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
103 103
             );
104 104
         }
105
-        if($job->getDatePublishStart()){
105
+        if ($job->getDatePublishStart()) {
106 106
             $document->addField('datePublishStart',
107 107
                 $job->getDatePublishStart()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
108 108
             );
109 109
         }
110 110
 
111
-        if($job->getDatePublishEnd()){
111
+        if ($job->getDatePublishEnd()) {
112 112
             $document->addField('datePublishEnd',
113 113
                 $job->getDatePublishEnd()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
114 114
             );
115 115
         }
116 116
 
117
-        $document->addField('isActive',$job->isActive());
118
-        $document->addField('lang',$job->getLanguage());
117
+        $document->addField('isActive', $job->isActive());
118
+        $document->addField('lang', $job->getLanguage());
119 119
 
120
-        $this->processLocation($job,$document);
121
-        if(!is_null($job->getOrganization())){
122
-            $this->processOrganization($job,$document);
120
+        $this->processLocation($job, $document);
121
+        if (!is_null($job->getOrganization())) {
122
+            $this->processOrganization($job, $document);
123 123
         }
124 124
         return $document;
125 125
     }
126 126
 
127
-    public function processOrganization(Job $job,$document)
127
+    public function processOrganization(Job $job, $document)
128 128
     {
129
-        if(!is_null($job->getOrganization()->getImage())){
129
+        if (!is_null($job->getOrganization()->getImage())) {
130 130
             $uri = $job->getOrganization()->getImage()->getUri();
131
-            $document->addField('companyLogo',$uri);
131
+            $document->addField('companyLogo', $uri);
132 132
         }
133
-        $document->addField('organizationName',$job->getOrganization()->getOrganizationName()->getName());
133
+        $document->addField('organizationName', $job->getOrganization()->getOrganizationName()->getName());
134 134
         // @TODO: uncomment this when organization id is fix
135 135
         //$document->addField('organizationId',$job->getOrganization()->getId());
136 136
     }
137 137
 
138
-    public function processLocation(Job $job,$document)
138
+    public function processLocation(Job $job, $document)
139 139
     {
140 140
         /* @var \Jobs\Entity\Location $location */
141
-        foreach($job->getLocations() as $location){
141
+        foreach ($job->getLocations() as $location) {
142 142
             $coord = $location->getCoordinates()->getCoordinates();
143
-            $document->addField('latLon',doubleval($coord[0]).','.doubleval($coord[1]));
144
-            $document->addField('postCode',$location->getPostalCode());
145
-            $document->addField('regionText',$location->getRegion());
143
+            $document->addField('latLon', doubleval($coord[0]).','.doubleval($coord[1]));
144
+            $document->addField('postCode', $location->getPostalCode());
145
+            $document->addField('regionText', $location->getRegion());
146 146
         }
147 147
 
148
-        $document->addField('location',$job->getLocation());
148
+        $document->addField('location', $job->getLocation());
149 149
     }
150 150
 }
151 151
\ 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
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         $solrDoc = $this->generateInputDocument($document, new \SolrInputDocument());
53 53
         try{
54 54
             $this->solrManager->addDocument($solrDoc,'/solr/YawikJobs');
55
-        }catch (\Exception $e){
55
+        } catch (\Exception $e){
56 56
             // @TODO: What to do when the process failed?
57 57
         }
58 58
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $solrDoc = $this->generateInputDocument($document,new \SolrInputDocument());
68 68
         try{
69 69
             $this->solrManager->addDocument($solrDoc,'/solr/YawikJobs');
70
-        }catch (\Exception $e){
70
+        } catch (\Exception $e){
71 71
             // @TODO: What to do when the process failed?
72 72
         }
73 73
     }
Please login to merge, or discard this patch.
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/Core/src/Core/Controller/Plugin/CreatePaginator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         /* @var EventManager $eventManager */
92 92
         /* @var $paginator \Zend\Paginator\Paginator */
93 93
         $eventManager = $this->serviceManager->get('EventManager');
94
-        $response      = $eventManager->trigger(
94
+        $response = $eventManager->trigger(
95 95
             static::EVENT_CREATE_PAGINATOR,
96 96
             $this,
97 97
             [
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         );
102 102
         $paginator = $response->last(); // get the last result from listener
103 103
 
104
-        if(!$paginator instanceof Paginator){
104
+        if (!$paginator instanceof Paginator) {
105 105
             // paginator is not created, so we create from service
106 106
             $paginator = $paginators->get($paginatorName, $params);
107 107
         }
Please login to merge, or discard this patch.
module/Solr/src/Solr/Bridge/ResultConverter.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -42,17 +42,17 @@  discard block
 block discarded – undo
42 42
         $propertiesMap = $filter->getPropertiesMap();
43 43
         $class = $filter->getEntityClass();
44 44
         $entities = [];
45
-        foreach($response['response']['docs'] as $doc){
45
+        foreach ($response['response']['docs'] as $doc) {
46 46
             $ob = new $class();
47 47
             $properties = $doc->getPropertyNames();
48
-            foreach($properties as $name){
48
+            foreach ($properties as $name) {
49 49
                 $setter = 'set'.$name;
50 50
                 $value = $doc->$name;
51 51
                 $value = $this->validateDate($value);
52
-                if(method_exists($ob,$setter)){
53
-                    call_user_func(array($ob,$setter),$value);
54
-                }elseif(isset($propertiesMap[$name])){
55
-                    $this->handleMappedProperty($propertiesMap[$name],$ob,$value);
52
+                if (method_exists($ob, $setter)) {
53
+                    call_user_func(array($ob, $setter), $value);
54
+                }elseif (isset($propertiesMap[$name])) {
55
+                    $this->handleMappedProperty($propertiesMap[$name], $ob, $value);
56 56
                 }
57 57
 
58 58
             }
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
      * @param $object
70 70
      * @param $value
71 71
      */
72
-    public function handleMappedProperty($property,$object,$value)
72
+    public function handleMappedProperty($property, $object, $value)
73 73
     {
74
-        $callback = array($this->filter,$property);
75
-        if(is_callable($callback)){
76
-            call_user_func($callback,$object,$value);
74
+        $callback = array($this->filter, $property);
75
+        if (is_callable($callback)) {
76
+            call_user_func($callback, $object, $value);
77 77
         }
78 78
     }
79 79
 
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
     public function validateDate($value)
87 87
     {
88 88
         $value = trim($value);
89
-        $date = \DateTime::createFromFormat(Manager::SOLR_DATE_FORMAT,$value);
89
+        $date = \DateTime::createFromFormat(Manager::SOLR_DATE_FORMAT, $value);
90 90
         $check = $date && ($date->format(Manager::SOLR_DATE_FORMAT) === $value);
91
-        if($check){
91
+        if ($check) {
92 92
             return $date;
93
-        }else{
93
+        } else {
94 94
             return $value;
95 95
         }
96 96
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                 $value = $this->validateDate($value);
52 52
                 if(method_exists($ob,$setter)){
53 53
                     call_user_func(array($ob,$setter),$value);
54
-                }elseif(isset($propertiesMap[$name])){
54
+                } elseif(isset($propertiesMap[$name])){
55 55
                     $this->handleMappedProperty($propertiesMap[$name],$ob,$value);
56 56
                 }
57 57
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         $check = $date && ($date->format(Manager::SOLR_DATE_FORMAT) === $value);
91 91
         if($check){
92 92
             return $date;
93
-        }else{
93
+        } else{
94 94
             return $value;
95 95
         }
96 96
     }
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
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param   ResultConverter             $resultConverter
62 62
      * @param   array                       $params
63 63
      */
64
-    public function __construct($client,$filter,$resultConverter,$params=array())
64
+    public function __construct($client, $filter, $resultConverter, $params = array())
65 65
     {
66 66
         $this->client           = $client;
67 67
         $this->filter           = $filter;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         return $this->resultConverter->convert(
78 78
             $this->filter,
79
-            $this->getResponse($offset,$itemCountPerPage)
79
+            $this->getResponse($offset, $itemCountPerPage)
80 80
         );
81 81
     }
82 82
 
@@ -99,18 +99,18 @@  discard block
 block discarded – undo
99 99
      * @return  \SolrQueryResponse
100 100
      * @throws  \Exception
101 101
      */
102
-    protected function getResponse($offset=0,$itemCountPerPage=5)
102
+    protected function getResponse($offset = 0, $itemCountPerPage = 5)
103 103
     {
104
-        if(!is_object($this->response)){
104
+        if (!is_object($this->response)) {
105 105
             $query = new \SolrQuery();
106
-            $query = $this->filter->filter($this->params,$query);
106
+            $query = $this->filter->filter($this->params, $query);
107 107
             $query->setStart($offset);
108 108
             $query->setRows($itemCountPerPage);
109
-            try{
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
-                throw new ServerException($message,$e->getCode(),$e);
113
+                throw new ServerException($message, $e->getCode(), $e);
114 114
             }
115 115
         }
116 116
         return $this->response;
Please login to merge, or discard this patch.
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.
module/Solr/src/Solr/Event/Listener/CreatePaginatorListener.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
         $this->listeners[] = $sharedEvents->attach(
41 41
             '*',
42 42
             CreatePaginator::EVENT_CREATE_PAGINATOR,
43
-            array($this,'onCreatePaginator'),
43
+            array($this, 'onCreatePaginator'),
44 44
             1
45 45
         );
46 46
     }
47 47
 
48 48
     public function detach(EventManagerInterface $events)
49 49
     {
50
-        foreach($this->listeners as $index=>$listener){
51
-            if($events->detach($listener)){
50
+        foreach ($this->listeners as $index=>$listener) {
51
+            if ($events->detach($listener)) {
52 52
                 unset($this->listeners[$index]);
53 53
             }
54 54
         }
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
         $paginatorName = $params['paginatorName'];
62 62
         $paginators = $this->paginators;
63 63
         $serviceName = 'Solr/'.$paginatorName;
64
-        if($paginators->has($serviceName)){
64
+        if ($paginators->has($serviceName)) {
65 65
             // yes, we have that solr paginator to replace $paginatorName
66
-            $service = $paginators->get($serviceName,$params['params']);
66
+            $service = $paginators->get($serviceName, $params['params']);
67 67
         }
68 68
         return $service;
69 69
     }
Please login to merge, or discard this patch.
module/Solr/src/Solr/Filter/JobBoardPaginationQuery.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,27 +36,27 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function createQuery(array $params, $query)
38 38
     {
39
-        $search = isset($params['search']) ? $params['search']:'';
39
+        $search = isset($params['search']) ? $params['search'] : '';
40 40
 
41
-        if(!empty($search)){
41
+        if (!empty($search)) {
42 42
             $q = 'title:'.$search.' OR organizationName:'.$search;
43
-        }else{
43
+        } else {
44 44
             $q = '*:*';
45 45
         }
46 46
 
47 47
         $query->setQuery($q);
48 48
         
49
-        if(isset($params['sort'])){
49
+        if (isset($params['sort'])) {
50 50
             $sorts = $this->filterSort($params['sort']);
51
-            foreach($sorts as $field=>$order){
52
-                $query->addSortField($field,$order);
51
+            foreach ($sorts as $field=>$order) {
52
+                $query->addSortField($field, $order);
53 53
             }
54 54
         }
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_null($location->getCoordinates())){
59
+            if (!is_null($location->getCoordinates())) {
60 60
                 $coordinates = $location->getCoordinates()->getCoordinates();
61 61
                 $query->addFilterQuery(sprintf(
62 62
                     "{!geofilt pt=%s sfield=latLon d=%s}",
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
      * @param Job       $ob
83 83
      * @param string    $value
84 84
      */
85
-    public function convertOrganizationName($ob,$value)
85
+    public function convertOrganizationName($ob, $value)
86 86
     {
87
-        if(!is_object($ob->getOrganization())){
87
+        if (!is_object($ob->getOrganization())) {
88 88
             $ob->setOrganization(new Organization());
89 89
         }
90 90
         $orgName = new OrganizationName($value);
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
      * @param   Job     $ob
97 97
      * @param   mixed   $value
98 98
      */
99
-    public function convertCompanyLogo($ob,$value)
99
+    public function convertCompanyLogo($ob, $value)
100 100
     {
101
-        if(!is_object($ob->getOrganization())){
101
+        if (!is_object($ob->getOrganization())) {
102 102
             $ob->setOrganization(new Organization());
103 103
         }
104
-        $exp    = explode('/',$value);
104
+        $exp    = explode('/', $value);
105 105
         $id     = $exp[3];
106 106
         $name   = $exp[4];
107 107
         $image = new OrganizationImage();
Please login to merge, or discard this patch.
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.
module/Solr/src/Solr/Filter/AbstractPaginationQuery.php 1 patch
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.