Completed
Pull Request — develop (#462)
by ANTHONIUS
09:40
created
module/Organizations/src/Organizations/Controller/ProfileController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         $repo            = $this->repo;
103 103
         $id              = $this->params('id');
104 104
 
105
-        if(is_null($id)){
105
+        if (is_null($id)) {
106 106
             $this->getResponse()->setStatusCode(Response::STATUS_CODE_404);
107 107
             return [
108 108
                 'message' => $translator->translate('Can not access profile page without id'),
@@ -111,38 +111,38 @@  discard block
 block discarded – undo
111 111
         }
112 112
 
113 113
         $organization = $repo->find($id);
114
-        if(!$organization instanceof Organization){
114
+        if (!$organization instanceof Organization) {
115 115
             throw new NotFoundException($id);
116 116
         }
117 117
 
118
-        if(
118
+        if (
119 119
             Organization::PROFILE_DISABLED == $organization->getProfileSetting()
120 120
             || is_null($organization->getProfileSetting())
121
-        ){
121
+        ) {
122 122
             throw new UnauthorizedAccessException(/*@translate*/ 'This Organization Profile is disabled');
123 123
         }
124 124
 
125 125
         $result = $this->pagination([
126 126
             'params' => [
127
-                'Organization_Jobs',[
127
+                'Organization_Jobs', [
128 128
                     'organization_id' => $organization->getId()
129 129
                 ],
130 130
             ],
131 131
             'paginator' => [
132
-                'as' => 'jobs','Organizations/ListJob',
132
+                'as' => 'jobs', 'Organizations/ListJob',
133 133
                 'params' => [
134 134
                     'count' => 2,
135 135
                 ]
136 136
             ],
137 137
         ]);
138 138
 
139
-        if(
139
+        if (
140 140
             Organization::PROFILE_ACTIVE_JOBS == $organization->getProfileSetting()
141
-        ){
141
+        ) {
142 142
             /* @var \Zend\Paginator\Paginator $paginator */
143 143
             $paginator = $result['jobs'];
144 144
             $count = $paginator->getTotalItemCount();
145
-            if(0===$count){
145
+            if (0 === $count) {
146 146
                 throw new UnauthorizedAccessException(/*@translate*/ 'This Organization Profile is disabled');
147 147
             }
148 148
         }
Please login to merge, or discard this patch.
Organizations/src/Organizations/Repository/Filter/PaginationQuery.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      *
32 32
      * @var String
33 33
      */
34
-    protected $repositoryName="Organizations/Organization";
34
+    protected $repositoryName = "Organizations/Organization";
35 35
     
36 36
     /**
37 37
      * Sortable fields
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             $value = $params;
74 74
         }
75 75
 
76
-        if (isset($params['q']) && $params['q'] && $params['q'] != 'en/organizations/profile' ) {
76
+        if (isset($params['q']) && $params['q'] && $params['q'] != 'en/organizations/profile') {
77 77
             $queryBuilder->text($params['q'])->language('none');
78 78
         }
79 79
 
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
 
84 84
         $queryBuilder->sort($this->filterSort($value['sort']));
85 85
 
86
-        if(isset($params['type']) && $params['type'] === 'profile'){
86
+        if (isset($params['type']) && $params['type'] === 'profile') {
87 87
             //@TODO: we should use aggregate query here
88 88
             $queryBuilder->field('profileSetting')
89
-                ->in([Organization::PROFILE_ALWAYS_ENABLE,Organization::PROFILE_ACTIVE_JOBS])
89
+                ->in([Organization::PROFILE_ALWAYS_ENABLE, Organization::PROFILE_ACTIVE_JOBS])
90 90
             ;
91 91
 
92 92
             $filters = $this->getOrganizationProfileFilters($queryBuilder);
93
-            if(count($filters) > 0){
93
+            if (count($filters) > 0) {
94 94
                 $queryBuilder->field('id')->notIn($filters);
95 95
             }
96 96
 
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
         $results = $queryBuilder->getQuery()->execute();
111 111
 
112 112
         $filters = [];
113
-        foreach($results->toArray() as $organization){
114
-            if($organization->getProfileSetting()==Organization::PROFILE_ACTIVE_JOBS){
113
+        foreach ($results->toArray() as $organization) {
114
+            if ($organization->getProfileSetting() == Organization::PROFILE_ACTIVE_JOBS) {
115 115
                 $qb = $jobRepository->createQueryBuilder();
116 116
                 $qb
117 117
                     ->field('organization')->equals($organization->getId())
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                     ->field('isDraft')->notEqual(true)
120 120
                 ;
121 121
                 $count = $qb->getQuery()->execute()->count();
122
-                if($count == 0){
122
+                if ($count == 0) {
123 123
                     $filters[] = $organization->getId();
124 124
                 }
125 125
             }
Please login to merge, or discard this patch.
module/Behat/src/OrganizationContext.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class OrganizationContext implements Context
32 32
 {
33
-	use CommonContextTrait;
33
+    use CommonContextTrait;
34 34
 
35 35
     /**
36 36
      * @var JobContext
37 37
      */
38
-	private $jobContext;
38
+    private $jobContext;
39 39
 
40 40
     /**
41 41
      * @BeforeScenario
@@ -47,51 +47,51 @@  discard block
 block discarded – undo
47 47
         $this->jobContext = $scope->getEnvironment()->getContext(JobContext::class);
48 48
     }
49 49
 
50
-	/**
51
-	 * @Given I go to my organization page
52
-	 */
53
-	public function iGoToMyOrganizationPage()
54
-	{
50
+    /**
51
+     * @Given I go to my organization page
52
+     */
53
+    public function iGoToMyOrganizationPage()
54
+    {
55 55
         $url = $this->buildUrl('lang/my-organization');
56
-		$this->visit($url);
57
-	}
56
+        $this->visit($url);
57
+    }
58 58
 	
59
-	/**
60
-	 * @When I hover over name form
61
-	 */
62
-	public function iMouseOverOrganizationNameForm()
63
-	{
64
-		$locator = '#sf-nameForm .sf-summary';
65
-		$this->coreContext->iHoverOverTheElement($locator);
66
-	}
59
+    /**
60
+     * @When I hover over name form
61
+     */
62
+    public function iMouseOverOrganizationNameForm()
63
+    {
64
+        $locator = '#sf-nameForm .sf-summary';
65
+        $this->coreContext->iHoverOverTheElement($locator);
66
+    }
67 67
 	
68
-	/**
69
-	 * @Given I go to create new organization page
70
-	 */
71
-	public function iGoToCreateNewOrganizationPage()
72
-	{
73
-		//$this->visit('/organizations/edit');
68
+    /**
69
+     * @Given I go to create new organization page
70
+     */
71
+    public function iGoToCreateNewOrganizationPage()
72
+    {
73
+        //$this->visit('/organizations/edit');
74 74
         $url = $this->buildUrl('lang/organizations/edit');
75 75
         $this->visit($url);
76
-	}
76
+    }
77 77
 	
78
-	/**
79
-	 * @Given I go to organization overview page
80
-	 */
81
-	public function iGoToOrganizationOverviewPage()
82
-	{
83
-		//$this->visit('/organizations');
84
-		$url = $this->buildUrl('lang/organizations');
85
-		$this->visit($url);
86
-	}
78
+    /**
79
+     * @Given I go to organization overview page
80
+     */
81
+    public function iGoToOrganizationOverviewPage()
82
+    {
83
+        //$this->visit('/organizations');
84
+        $url = $this->buildUrl('lang/organizations');
85
+        $this->visit($url);
86
+    }
87 87
 
88 88
     /**
89 89
      * @Given I want to see list organization profiles
90 90
      */
91
-	public function iWantToSeeListOrganizationProfiles()
91
+    public function iWantToSeeListOrganizationProfiles()
92 92
     {
93
-       $url = $this->buildUrl('lang/organizations/profile');
94
-       $this->visit($url);
93
+        $url = $this->buildUrl('lang/organizations/profile');
94
+        $this->visit($url);
95 95
     }
96 96
 
97 97
     /**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      * @internal param string $name
101 101
      * @internal param TableNode|null $table
102 102
      */
103
-	public function iHaveOrganization($name)
103
+    public function iHaveOrganization($name)
104 104
     {
105 105
         $user = $this->getUserContext()->getCurrentUser();
106 106
         $organization = $this->findOrganizationByName($name,false);
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 	public function iHaveOrganization($name)
104 104
     {
105 105
         $user = $this->getUserContext()->getCurrentUser();
106
-        $organization = $this->findOrganizationByName($name,false);
106
+        $organization = $this->findOrganizationByName($name, false);
107 107
         $repo = $this->getRepository('Organizations/Organization');
108
-        if(!$organization instanceof Organization){
108
+        if (!$organization instanceof Organization) {
109 109
 
110 110
             $organization = new Organization();
111 111
             $organizationName = new OrganizationName($name);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
         $organization->setParent($parent);
119 119
         $organization->setProfileSetting(Organization::PROFILE_ALWAYS_ENABLE);
120 120
         $permissions = $organization->getPermissions();
121
-        $permissions->grant($user,Permissions::PERMISSION_ALL);
121
+        $permissions->grant($user, Permissions::PERMISSION_ALL);
122 122
 
123 123
         $repo->store($organization);
124 124
         $repo->getDocumentManager()->refresh($organization);
@@ -128,19 +128,19 @@  discard block
 block discarded – undo
128 128
     /**
129 129
      * @Given organization :name have jobs:
130 130
      */
131
-    public function organizationHavePublishedJob($name,TableNode $table)
131
+    public function organizationHavePublishedJob($name, TableNode $table)
132 132
     {
133 133
         $user = $this->getUserContext()->getCurrentUser();
134
-        if(is_null($user)){
134
+        if (is_null($user)) {
135 135
             throw new FailedExpectationException('Need to login first');
136 136
         }
137 137
 
138 138
         $organization = $this->findOrganizationByName($name);
139
-        foreach($table->getColumnsHash() as $index=>$definitions){
139
+        foreach ($table->getColumnsHash() as $index=>$definitions) {
140 140
             $definitions['user'] = $user->getLogin();
141
-            $status = isset($definitions['status']) ? $definitions['status']:'draft';
141
+            $status = isset($definitions['status']) ? $definitions['status'] : 'draft';
142 142
             unset($definitions['status']);
143
-            $this->jobContext->buildJob($status,$definitions,$organization);
143
+            $this->jobContext->buildJob($status, $definitions, $organization);
144 144
         }
145 145
     }
146 146
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      * @param $name
150 150
      * @param $setting
151 151
      */
152
-    public function profileSetting($name,$setting)
152
+    public function profileSetting($name, $setting)
153 153
     {
154 154
         $repo = $this->getRepository('Organizations/Organization');
155 155
         $organization = $this->findOrganizationByName($name);
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
         $contact = $organization->getContact();
170 170
 
171 171
         $definitions = $table->getRowsHash();
172
-        foreach($definitions as $name=>$value){
172
+        foreach ($definitions as $name=>$value) {
173 173
             $field = Inflector::camelize($name);
174 174
             $method = 'set'.$field;
175
-            $callback = array($contact,$method);
176
-            if(is_callable($callback)){
177
-                call_user_func_array($callback,[$value]);
175
+            $callback = array($contact, $method);
176
+            if (is_callable($callback)) {
177
+                call_user_func_array($callback, [$value]);
178 178
             }
179 179
         }
180 180
         $this->getRepository('Organizations/Organization')->store($organization);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
     public function iGoToOrganizationProfilePage($name)
189 189
     {
190 190
         $organization = $this->findOrganizationByName($name);
191
-        $url = $this->buildUrl('lang/organizations/profileDetail',[
191
+        $url = $this->buildUrl('lang/organizations/profileDetail', [
192 192
             'id' => $organization->getId()
193 193
         ]);
194 194
 
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
         /* @var OrganizationRepository $repo */
206 206
         $repo = $this->getRepository('Organizations/Organization');
207 207
         $result = $repo->findByName($name);
208
-        $organization = count($result) > 0 ? $result[0]:null;
209
-        if(!$organization instanceof Organization && $throwException){
208
+        $organization = count($result) > 0 ? $result[0] : null;
209
+        if (!$organization instanceof Organization && $throwException) {
210 210
             throw new FailedExpectationException(
211
-                sprintf('Organization %s is not found.',$name)
211
+                sprintf('Organization %s is not found.', $name)
212 212
             );
213 213
         }
214 214
         return $organization;
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
         $jobRepo = $this->getRepository('Jobs/Job');
228 228
         $result = $jobRepo->findByOrganization($org->getId());
229 229
 
230
-        foreach($result as $job){
231
-            $jobRepo->remove($job,true);
230
+        foreach ($result as $job) {
231
+            $jobRepo->remove($job, true);
232 232
         }
233 233
     }
234 234
 }
Please login to merge, or discard this patch.