Completed
Push — develop ( cc6530...59407f )
by Mathias
08:03
created
module/Core/src/Core/Controller/Plugin/Mailer.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -87,11 +87,11 @@
 block discarded – undo
87 87
         return $sendMail ? $this->send($mail) : $mail;
88 88
     }
89 89
 	
90
-	/**
91
-	 * @param ContainerInterface $container
92
-	 *
93
-	 * @return Mailer
94
-	 */
90
+    /**
91
+     * @param ContainerInterface $container
92
+     *
93
+     * @return Mailer
94
+     */
95 95
     public static function factory(ContainerInterface $container)
96 96
     {
97 97
         return new static($container->get('Core/MailService'));
Please login to merge, or discard this patch.
module/Core/src/Core/Entity/AbstractIdentifiableEntity.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
  *
18 18
  * @author Anthonius Munthi <[email protected]>
19 19
  * @ODM\MappedSuperclass
20
-  */
20
+ */
21 21
 abstract class AbstractIdentifiableEntity extends AbstractEntity implements IdentifiableEntityInterface
22 22
 {
23 23
     use IdentifiableEntityTrait;
Please login to merge, or discard this patch.
module/Behat/src/MailContext.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -150,6 +150,9 @@
 block discarded – undo
150 150
         );
151 151
     }
152 152
 
153
+    /**
154
+     * @param string $contents
155
+     */
153 156
     private function parseEmail($contents)
154 157
     {
155 158
         $addresses = $this->parseEmailAddress($contents);
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $core = $scope->getEnvironment()->getContext(CoreContext::class);
50 50
         /* @var FileTransport $transport */
51 51
         $transport = $core->getServiceManager()->get('Core/MailService')->getTransport();
52
-        $path = $transport->getOptions()->getPath() . '/*.eml';
52
+        $path = $transport->getOptions()->getPath().'/*.eml';
53 53
         foreach (glob($path) as $filename) {
54 54
             unlink($filename);
55 55
         }
@@ -105,25 +105,25 @@  discard block
 block discarded – undo
105 105
         $regex = '/.*('.preg_quote($text).').*/im';
106 106
         $matches = [];
107 107
         $multiMessages = false;
108
-        if(count($this->messages) > 1){
108
+        if (count($this->messages) > 1) {
109 109
             $multiMessages = true;
110 110
         }
111 111
         $content = "";
112
-        foreach($this->messages as $key=>$definition){
112
+        foreach ($this->messages as $key=>$definition) {
113 113
             $content = $definition['contents'];
114
-            if(preg_match($regex,$content,$match)){
114
+            if (preg_match($regex, $content, $match)) {
115 115
                 $matches[] = $match;
116 116
             }
117 117
         }
118
-        $failMessage = sprintf('Can not find text "%s" in any email sent',$text);
119
-        if(!$multiMessages){
118
+        $failMessage = sprintf('Can not find text "%s" in any email sent', $text);
119
+        if (!$multiMessages) {
120 120
             $failMessage = sprintf(
121 121
                 'Can not find text "%s" in sent email. Here\'s the email content: %s',
122 122
                 $text,
123 123
                 PHP_EOL.PHP_EOL.$content
124 124
             );
125 125
         }
126
-        Assert::true(count($matches)>0,$failMessage);
126
+        Assert::true(count($matches) > 0, $failMessage);
127 127
     }
128 128
 
129 129
     /**
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
 
137 137
         $path = $transport->getOptions()->getPath().'/*.eml';
138 138
 
139
-        foreach(glob($path) as $filename){
139
+        foreach (glob($path) as $filename) {
140 140
             $id = md5($filename);
141
-            if(!isset($this->messages[$id])){
141
+            if (!isset($this->messages[$id])) {
142 142
                 $contents = file_get_contents($filename);
143
-                $this->messages[$id]  = $this->parseEmail($contents);
143
+                $this->messages[$id] = $this->parseEmail($contents);
144 144
             }
145 145
         }
146 146
 
147 147
         Assert::true(
148
-            count($this->messages)>0,
148
+            count($this->messages) > 0,
149 149
             'No email have been sent'
150 150
         );
151 151
     }
@@ -153,33 +153,33 @@  discard block
 block discarded – undo
153 153
     private function parseEmail($contents)
154 154
     {
155 155
         $addresses = $this->parseEmailAddress($contents);
156
-        $subject =$this->parseSubject($contents);
156
+        $subject = $this->parseSubject($contents);
157 157
 
158 158
         $contents = strip_tags($contents);
159 159
         $contents = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $contents);
160 160
 
161
-        return array_merge($addresses,$subject,['contents' => $contents]);
161
+        return array_merge($addresses, $subject, ['contents' => $contents]);
162 162
     }
163 163
 
164 164
     private function parseEmailAddress($contents)
165 165
     {
166 166
         // pattern to get email address
167
-        $radd =  '(\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\b)';
167
+        $radd = '(\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\b)';
168 168
 
169 169
         // get email from address
170
-        $regex = sprintf('/^From\:.*%s/im',$radd);
171
-        $hasMatch = preg_match($regex,$contents,$matches);
172
-        $fromAddress = $hasMatch ? $matches[1]:null;
170
+        $regex = sprintf('/^From\:.*%s/im', $radd);
171
+        $hasMatch = preg_match($regex, $contents, $matches);
172
+        $fromAddress = $hasMatch ? $matches[1] : null;
173 173
 
174 174
         // get email to address
175
-        $regex = sprintf('/^To\:\s+%s/im',$radd);
176
-        $hasMatch = preg_match($regex,$contents,$matches);
177
-        $toAddress1 = $hasMatch ? $matches[1]:null;
175
+        $regex = sprintf('/^To\:\s+%s/im', $radd);
176
+        $hasMatch = preg_match($regex, $contents, $matches);
177
+        $toAddress1 = $hasMatch ? $matches[1] : null;
178 178
 
179 179
         // get email to address
180
-        $regex = sprintf('/^To\:.*%s/im',$radd);
181
-        $hasMatch = preg_match($regex,$contents,$matches);
182
-        $toAddress2 = $hasMatch ? $matches[1]:null;
180
+        $regex = sprintf('/^To\:.*%s/im', $radd);
181
+        $hasMatch = preg_match($regex, $contents, $matches);
182
+        $toAddress2 = $hasMatch ? $matches[1] : null;
183 183
 
184 184
         $this->fromMails[] = $fromAddress;
185 185
         $this->toMails[] = $toAddress1;
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 
188 188
         return [
189 189
             'from' => $fromAddress,
190
-            'to' => [$toAddress1,$toAddress2],
190
+            'to' => [$toAddress1, $toAddress2],
191 191
         ];
192 192
     }
193 193
 
194 194
     private function parseSubject($contents)
195 195
     {
196 196
         $pattern = '/Subject\:(.*)/i';
197
-        preg_match($pattern,$contents,$matches);
198
-        $subject = isset($matches[1]) ? $matches[1]:null;
197
+        preg_match($pattern, $contents, $matches);
198
+        $subject = isset($matches[1]) ? $matches[1] : null;
199 199
         $this->subjects[] = $subject;
200 200
         return [
201 201
             'subject' => trim($subject)
Please login to merge, or discard this patch.
module/Core/src/Core/Mail/FileTransport.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
     {
33 33
         $options  = $this->options;
34 34
         $filename = call_user_func($options->getCallback(), $this);
35
-        $file     = $options->getPath() . DIRECTORY_SEPARATOR . $filename;
35
+        $file     = $options->getPath().DIRECTORY_SEPARATOR.$filename;
36 36
 
37 37
 
38 38
         $contents = $message->toString();
Please login to merge, or discard this patch.
module/Core/src/Core/Mail/MailServiceFactory.php 3 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -26,41 +26,41 @@
 block discarded – undo
26 26
  */
27 27
 class MailServiceFactory implements FactoryInterface
28 28
 {
29
-	public function __invoke( ContainerInterface $container, $requestedName, array $options = null )
30
-	{
31
-		$config = $container->get('Config');
32
-		$mails = isset($config['mails']) ? $config['mails'] : [];
29
+    public function __invoke( ContainerInterface $container, $requestedName, array $options = null )
30
+    {
31
+        $config = $container->get('Config');
32
+        $mails = isset($config['mails']) ? $config['mails'] : [];
33 33
 		
34
-		/* @var \Auth\Options\ModuleOptions $authOptions */
35
-		$authOptions = $container->get('Auth/Options');
34
+        /* @var \Auth\Options\ModuleOptions $authOptions */
35
+        $authOptions = $container->get('Auth/Options');
36 36
 		
37
-		/* @var \Core\Options\MailServiceOptions $mailServiceOptions */
38
-		$mailServiceOptions = $container->get('Core/MailServiceOptions');
37
+        /* @var \Core\Options\MailServiceOptions $mailServiceOptions */
38
+        $mailServiceOptions = $container->get('Core/MailServiceOptions');
39 39
 		
40
-		$configArray = [
41
-			'from' => [
42
-				'name' => $authOptions->getFromName(),
43
-				'email' => $authOptions->getFromEmail()
44
-			],
45
-		];
40
+        $configArray = [
41
+            'from' => [
42
+                'name' => $authOptions->getFromName(),
43
+                'email' => $authOptions->getFromEmail()
44
+            ],
45
+        ];
46 46
 
47
-		$configArray['transport'] = $this->getTransport($mailServiceOptions);
48
-		$configArray = array_merge($configArray, $mails);
47
+        $configArray['transport'] = $this->getTransport($mailServiceOptions);
48
+        $configArray = array_merge($configArray, $mails);
49 49
 		
50
-		$config = new MailServiceConfig($configArray);
51
-		$service   = new MailService($container,$config->toArray());
52
-		$config->configureServiceManager($service);
53
-		foreach($config->toArray() as $name=>$value){
54
-			$method = 'set'.$name;
55
-			if(method_exists($service,$method)){
56
-				call_user_func([$service,$method],$value);
57
-			}
58
-		}
50
+        $config = new MailServiceConfig($configArray);
51
+        $service   = new MailService($container,$config->toArray());
52
+        $config->configureServiceManager($service);
53
+        foreach($config->toArray() as $name=>$value){
54
+            $method = 'set'.$name;
55
+            if(method_exists($service,$method)){
56
+                call_user_func([$service,$method],$value);
57
+            }
58
+        }
59 59
 		
60
-		return $service;
61
-	}
60
+        return $service;
61
+    }
62 62
 
63
-	public function getTransport(MailServiceOptions $mailServiceOptions)
63
+    public function getTransport(MailServiceOptions $mailServiceOptions)
64 64
     {
65 65
         $type = $mailServiceOptions->getTransportClass();
66 66
         if (MailService::TRANSPORT_SMTP == $type) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class MailServiceFactory implements FactoryInterface
28 28
 {
29
-	public function __invoke( ContainerInterface $container, $requestedName, array $options = null )
29
+	public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
30 30
 	{
31 31
 		$config = $container->get('Config');
32 32
 		$mails = isset($config['mails']) ? $config['mails'] : [];
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
 		$configArray = array_merge($configArray, $mails);
49 49
 		
50 50
 		$config = new MailServiceConfig($configArray);
51
-		$service   = new MailService($container,$config->toArray());
51
+		$service = new MailService($container, $config->toArray());
52 52
 		$config->configureServiceManager($service);
53
-		foreach($config->toArray() as $name=>$value){
53
+		foreach ($config->toArray() as $name=>$value) {
54 54
 			$method = 'set'.$name;
55
-			if(method_exists($service,$method)){
56
-				call_user_func([$service,$method],$value);
55
+			if (method_exists($service, $method)) {
56
+				call_user_func([$service, $method], $value);
57 57
 			}
58 58
 		}
59 59
 		
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
         $type = $mailServiceOptions->getTransportClass();
66 66
         if (MailService::TRANSPORT_SMTP == $type) {
67 67
             return new Smtp($mailServiceOptions);
68
-        }elseif(MailService::TRANSPORT_FILE == $type){
68
+        }elseif (MailService::TRANSPORT_FILE == $type) {
69 69
             $fileOptions = new FileOptions();
70 70
             $fileOptions->setPath($mailServiceOptions->getPath());
71 71
             return new FileTransport($fileOptions);
72
-        }elseif(MailService::TRANSPORT_SENDMAIL == $type){
72
+        }elseif (MailService::TRANSPORT_SENDMAIL == $type) {
73 73
             return new Sendmail();
74 74
         }
75 75
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,11 +65,11 @@
 block discarded – undo
65 65
         $type = $mailServiceOptions->getTransportClass();
66 66
         if (MailService::TRANSPORT_SMTP == $type) {
67 67
             return new Smtp($mailServiceOptions);
68
-        }elseif(MailService::TRANSPORT_FILE == $type){
68
+        } elseif(MailService::TRANSPORT_FILE == $type){
69 69
             $fileOptions = new FileOptions();
70 70
             $fileOptions->setPath($mailServiceOptions->getPath());
71 71
             return new FileTransport($fileOptions);
72
-        }elseif(MailService::TRANSPORT_SENDMAIL == $type){
72
+        } elseif(MailService::TRANSPORT_SENDMAIL == $type){
73 73
             return new Sendmail();
74 74
         }
75 75
 
Please login to merge, or discard this patch.
module/Core/src/Core/Options/MailServiceOptions.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         return $this;
100 100
     }
101 101
 
102
-    public function getUsername(){
102
+    public function getUsername() {
103 103
         return $this->connectionConfig['username'];
104 104
     }
105 105
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         return $this;
111 111
     }
112 112
 
113
-    public function getPassword(){
113
+    public function getPassword() {
114 114
         return $this->connectionConfig['password'];
115 115
     }
116 116
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         return $this;
122 122
     }
123 123
 
124
-    public function getSsl(){
124
+    public function getSsl() {
125 125
         return $this->connectionConfig['ssl'];
126 126
     }
127 127
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         return $this;
131 131
     }
132 132
 
133
-    public function getTransportClass(){
133
+    public function getTransportClass() {
134 134
         return $this->transportClass;
135 135
     }
136 136
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function getPath()
141 141
     {
142
-        if(is_null($this->path)){
142
+        if (is_null($this->path)) {
143 143
             $this->setPath(sys_get_temp_dir().'/yawik/mails');
144 144
         }
145 145
         return $this->path;
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function setPath($path)
153 153
     {
154
-        if(!is_dir($path)){
155
-            mkdir($path,0777,true);
156
-            chmod($path,0777);
154
+        if (!is_dir($path)) {
155
+            mkdir($path, 0777, true);
156
+            chmod($path, 0777);
157 157
         }
158 158
         $this->path = $path;
159 159
         return $this;
Please login to merge, or discard this patch.
module/Behat/src/JobContext.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -215,6 +215,9 @@
 block discarded – undo
215 215
 		$this->buildJob($status,$fields->getRowsHash());
216 216
 	}
217 217
 
218
+	/**
219
+	 * @param \Organizations\Entity\Organization $organization
220
+	 */
218 221
 	public function buildJob($status, $definitions,$organization = null)
219 222
     {
220 223
         $normalizedField = [
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		$element = $page->find('css',$mapMultiple[$field]);
185 185
 		if(!is_null($element) && $element->getAttribute('multiple')=='multiple'){
186 186
 			$this->minkContext->selectOption($value,$multipleField);
187
-		}else{
187
+		} else{
188 188
 			$locator = $mapSelect2[$field];
189 189
 			$this->select2Context->iFillInSelect2Field($locator,$value);
190 190
 		}
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
             if($user instanceof User){
248 248
                 $job->setUser($user);
249 249
                 $job->setOrganization($organization);
250
-            }else{
250
+            } else{
251 251
                 throw new \Exception('There is no user with this login:"'.$normalizedField['user'.'"']);
252 252
             }
253 253
         }
254 254
 
255 255
         if($status == 'draft'){
256 256
             $job->setIsDraft(true);
257
-        }elseif($status == 'published'){
257
+        } elseif($status == 'published'){
258 258
             $job->setIsDraft(false);
259 259
             $job->setDatePublishStart(new \DateTime());
260 260
         }
Please login to merge, or discard this patch.
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -34,188 +34,188 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class JobContext implements Context
36 36
 {
37
-	use CommonContextTrait;
37
+    use CommonContextTrait;
38 38
 	
39
-	/**
40
-	 * @var Select2Context
41
-	 */
42
-	private $select2Context;
39
+    /**
40
+     * @var Select2Context
41
+     */
42
+    private $select2Context;
43 43
 	
44
-	/**
45
-	 * @var Job
46
-	 */
47
-	private $currentJob;
44
+    /**
45
+     * @var Job
46
+     */
47
+    private $currentJob;
48 48
 	
49
-	/**
50
-	 * @var JobRepository
51
-	 */
52
-	static private $jobRepo;
49
+    /**
50
+     * @var JobRepository
51
+     */
52
+    static private $jobRepo;
53 53
 	
54
-	/**
55
-	 * @param User $user
56
-	 */
57
-	static public function removeJobByUser(User $user)
58
-	{
59
-		$repo = static::$jobRepo;
60
-		$results = $repo->findBy(['user' => $user]);
61
-		foreach($results as $result){
62
-			$repo->remove($result,true);
63
-		}
64
-	}
54
+    /**
55
+     * @param User $user
56
+     */
57
+    static public function removeJobByUser(User $user)
58
+    {
59
+        $repo = static::$jobRepo;
60
+        $results = $repo->findBy(['user' => $user]);
61
+        foreach($results as $result){
62
+            $repo->remove($result,true);
63
+        }
64
+    }
65 65
 	
66
-	/**
67
-	 * @BeforeScenario
68
-	 *
69
-	 * @param BeforeScenarioScope $scope
70
-	 */
71
-	public function beforeScenario(BeforeScenarioScope $scope)
72
-	{
73
-		$this->select2Context = $scope->getEnvironment()->getContext(Select2Context::class);
74
-		if(is_null(static::$jobRepo)){
75
-			$this->gatherContexts($scope);
76
-			static::$jobRepo = $this->getJobRepository();
77
-		}
78
-	}
66
+    /**
67
+     * @BeforeScenario
68
+     *
69
+     * @param BeforeScenarioScope $scope
70
+     */
71
+    public function beforeScenario(BeforeScenarioScope $scope)
72
+    {
73
+        $this->select2Context = $scope->getEnvironment()->getContext(Select2Context::class);
74
+        if(is_null(static::$jobRepo)){
75
+            $this->gatherContexts($scope);
76
+            static::$jobRepo = $this->getJobRepository();
77
+        }
78
+    }
79 79
 	
80
-	/**
81
-	 * @Given I go to job board page
82
-	 */
83
-	public function iGoToJobBoardPage()
84
-	{
85
-		$this->visit('/jobboard');
86
-	}
80
+    /**
81
+     * @Given I go to job board page
82
+     */
83
+    public function iGoToJobBoardPage()
84
+    {
85
+        $this->visit('/jobboard');
86
+    }
87 87
 	
88
-	/**
89
-	 * @Given I go to create job page
90
-	 */
91
-	public function iGoToCreateJob()
92
-	{
93
-	    $url = $this->buildUrl('lang/jobs/manage',['action' => 'edit']);
94
-		$this->visit($url);
95
-	}
88
+    /**
89
+     * @Given I go to create job page
90
+     */
91
+    public function iGoToCreateJob()
92
+    {
93
+        $url = $this->buildUrl('lang/jobs/manage',['action' => 'edit']);
94
+        $this->visit($url);
95
+    }
96 96
 	
97
-	/**
98
-	 * @Given I go to job overview page
99
-	 */
100
-	public function iGoToJobOverviewPage()
101
-	{
102
-		$this->visit('/jobs');
103
-	}
97
+    /**
98
+     * @Given I go to job overview page
99
+     */
100
+    public function iGoToJobOverviewPage()
101
+    {
102
+        $this->visit('/jobs');
103
+    }
104 104
 	
105
-	/**
106
-	 * @Given I go to edit job draft with title :jobTitle
107
-	 * @param $jobTitle
108
-	 * @throws \Exception when job is not found
109
-	 */
110
-	public function iGoToEditJobWithTitle($jobTitle)
111
-	{
112
-		$job = $this->getJobRepository()->findOneBy(['title' => $jobTitle]);
113
-		if(!$job instanceof Job){
114
-			throw new \Exception(sprintf('Job with title "%s" is not found',$jobTitle));
115
-		}
116
-		$this->currentJob = $job;
117
-		$url = $this->buildUrl('lang/jobs/manage',[
118
-		    'id' => $job->getId()
105
+    /**
106
+     * @Given I go to edit job draft with title :jobTitle
107
+     * @param $jobTitle
108
+     * @throws \Exception when job is not found
109
+     */
110
+    public function iGoToEditJobWithTitle($jobTitle)
111
+    {
112
+        $job = $this->getJobRepository()->findOneBy(['title' => $jobTitle]);
113
+        if(!$job instanceof Job){
114
+            throw new \Exception(sprintf('Job with title "%s" is not found',$jobTitle));
115
+        }
116
+        $this->currentJob = $job;
117
+        $url = $this->buildUrl('lang/jobs/manage',[
118
+            'id' => $job->getId()
119 119
         ]);
120
-		$this->visit($url);
121
-	}
120
+        $this->visit($url);
121
+    }
122 122
 	
123
-	/**
124
-	 * @Given I don't have any classification data
125
-	 */
126
-	public function iDonTHaveAnyClassificationData()
127
-	{
128
-		$this->currentJob->setClassifications(new Classifications());
129
-		$this->getJobRepository()->store($this->currentJob);
130
-	}
123
+    /**
124
+     * @Given I don't have any classification data
125
+     */
126
+    public function iDonTHaveAnyClassificationData()
127
+    {
128
+        $this->currentJob->setClassifications(new Classifications());
129
+        $this->getJobRepository()->store($this->currentJob);
130
+    }
131 131
 	
132
-	/**
133
-	 * @When I don't have any posted job
134
-	 */
135
-	public function iDonTHaveAnyPostedJob()
136
-	{
137
-		/* @var $jobRepository JobRepository */
138
-		/* @var $job Job */
139
-		$user = $this->getUserContext()->getCurrentUser();
132
+    /**
133
+     * @When I don't have any posted job
134
+     */
135
+    public function iDonTHaveAnyPostedJob()
136
+    {
137
+        /* @var $jobRepository JobRepository */
138
+        /* @var $job Job */
139
+        $user = $this->getUserContext()->getCurrentUser();
140 140
 
141
-		$jobRepository = $this->getJobRepository();
142
-		$results = $jobRepository->getUserJobs($user->getId());
143
-		foreach($results as $job){
144
-			$jobRepository->remove($job,true);
145
-		}
146
-		$this->currentJob = null;
147
-	}
141
+        $jobRepository = $this->getJobRepository();
142
+        $results = $jobRepository->getUserJobs($user->getId());
143
+        foreach($results as $job){
144
+            $jobRepository->remove($job,true);
145
+        }
146
+        $this->currentJob = null;
147
+    }
148 148
 	
149
-	/**
150
-	 * @When I fill job location search with :search and choose :choice
151
-	 *
152
-	 */
153
-	public function iFillJobLocationAndChoose($search,$choice)
154
-	{
155
-		$select2 = $this->select2Context;
156
-		$select2->iFillInSelect2FieldWith('jobBase[geoLocation]',$search,$choice);
157
-	}
149
+    /**
150
+     * @When I fill job location search with :search and choose :choice
151
+     *
152
+     */
153
+    public function iFillJobLocationAndChoose($search,$choice)
154
+    {
155
+        $select2 = $this->select2Context;
156
+        $select2->iFillInSelect2FieldWith('jobBase[geoLocation]',$search,$choice);
157
+    }
158 158
 	
159
-	/**
160
-	 * @When I choose :value from :field
161
-	 */
162
-	public function iJobClassificationSelect($value,$field)
163
-	{
164
-		$field = Inflector::camelize($field);
159
+    /**
160
+     * @When I choose :value from :field
161
+     */
162
+    public function iJobClassificationSelect($value,$field)
163
+    {
164
+        $field = Inflector::camelize($field);
165 165
 		
166
-		$mapSelect2 = [
167
-			'professions' => '#classifications-professions-span .select2-container',
168
-			'industries'  => '#classifications-industries-span .select2-container',
169
-			'employmentTypes' => '#classifications-employmentTypes-span .select2-container',
170
-		];
166
+        $mapSelect2 = [
167
+            'professions' => '#classifications-professions-span .select2-container',
168
+            'industries'  => '#classifications-industries-span .select2-container',
169
+            'employmentTypes' => '#classifications-employmentTypes-span .select2-container',
170
+        ];
171 171
 		
172
-		$mapMultiple = [
173
-			'professions'       => "select#classifications-professions",
174
-			'industries'        => "select#classifications-industries",
175
-			'employmentTypes'    => "select#classifications-employmentTypes",
176
-		];
172
+        $mapMultiple = [
173
+            'professions'       => "select#classifications-professions",
174
+            'industries'        => "select#classifications-industries",
175
+            'employmentTypes'    => "select#classifications-employmentTypes",
176
+        ];
177 177
 		
178
-		if(!isset($mapSelect2[$field])){
179
-			throw new \Exception('Undefined field selection value "'.$field.'"');
180
-		}
178
+        if(!isset($mapSelect2[$field])){
179
+            throw new \Exception('Undefined field selection value "'.$field.'"');
180
+        }
181 181
 		
182
-		$multipleField = $mapMultiple[$field];
183
-		$page = $this->minkContext->getSession()->getPage();
184
-		$element = $page->find('css',$mapMultiple[$field]);
185
-		if(!is_null($element) && $element->getAttribute('multiple')=='multiple'){
186
-			$this->minkContext->selectOption($value,$multipleField);
187
-		}else{
188
-			$locator = $mapSelect2[$field];
189
-			$this->select2Context->iFillInSelect2Field($locator,$value);
190
-		}
191
-	}
182
+        $multipleField = $mapMultiple[$field];
183
+        $page = $this->minkContext->getSession()->getPage();
184
+        $element = $page->find('css',$mapMultiple[$field]);
185
+        if(!is_null($element) && $element->getAttribute('multiple')=='multiple'){
186
+            $this->minkContext->selectOption($value,$multipleField);
187
+        }else{
188
+            $locator = $mapSelect2[$field];
189
+            $this->select2Context->iFillInSelect2Field($locator,$value);
190
+        }
191
+    }
192 192
 	
193
-	/**
194
-	 * @return JobRepository
195
-	 */
196
-	public function getJobRepository()
197
-	{
198
-		return $this->getRepository('Jobs/Job');
199
-	}
193
+    /**
194
+     * @return JobRepository
195
+     */
196
+    public function getJobRepository()
197
+    {
198
+        return $this->getRepository('Jobs/Job');
199
+    }
200 200
 	
201
-	/**
202
-	 * @return CategoriesRepo
203
-	 */
204
-	public function getCategoriesRepository()
205
-	{
206
-		return $this->getRepository('Jobs/Category');
207
-	}
201
+    /**
202
+     * @return CategoriesRepo
203
+     */
204
+    public function getCategoriesRepository()
205
+    {
206
+        return $this->getRepository('Jobs/Category');
207
+    }
208 208
 	
209
-	/**
210
-	 * @When I have a :status job with the following:
211
-	 * @param TableNode $fields
212
-	 */
213
-	public function iHaveAJobWithTheFollowing($status,TableNode $fields)
214
-	{
215
-		$this->buildJob($status,$fields->getRowsHash());
216
-	}
209
+    /**
210
+     * @When I have a :status job with the following:
211
+     * @param TableNode $fields
212
+     */
213
+    public function iHaveAJobWithTheFollowing($status,TableNode $fields)
214
+    {
215
+        $this->buildJob($status,$fields->getRowsHash());
216
+    }
217 217
 
218
-	public function buildJob($status, $definitions,$organization = null)
218
+    public function buildJob($status, $definitions,$organization = null)
219 219
     {
220 220
         $normalizedField = [
221 221
             'template' => 'modern',
@@ -284,84 +284,84 @@  discard block
 block discarded – undo
284 284
     }
285 285
 
286 286
 	
287
-	private function setLocation(Job $job, $term)
288
-	{
289
-		/* @var $client Photon */
290
-		$client = $this->coreContext->getServiceManager()->get('Geo/Client');
291
-		$result = $client->queryOne($term);
292
-		$location = new Location();
293
-		$serialized = Json::encode($result);
294
-		$location->fromString($serialized);
287
+    private function setLocation(Job $job, $term)
288
+    {
289
+        /* @var $client Photon */
290
+        $client = $this->coreContext->getServiceManager()->get('Geo/Client');
291
+        $result = $client->queryOne($term);
292
+        $location = new Location();
293
+        $serialized = Json::encode($result);
294
+        $location->fromString($serialized);
295 295
 		
296
-		$locations = $job->getLocations();
297
-		if(count($locations)){
298
-			$locations->clear();
299
-		}
300
-		$job->getLocations()->add($location);
301
-	}
296
+        $locations = $job->getLocations();
297
+        if(count($locations)){
298
+            $locations->clear();
299
+        }
300
+        $job->getLocations()->add($location);
301
+    }
302 302
 	
303
-	private function addProfessions(Job &$job,$terms)
304
-	{
305
-		$professions = $this->getCategories($terms);
306
-		foreach($professions as $profession){
307
-			$values = $job->getClassifications()->getProfessions()->getValues();
308
-			if(!is_array($values) || !in_array($profession,$values)){
309
-				$job->getClassifications()->getProfessions()->getItems()->add($profession);
310
-			}
311
-		}
312
-	}
303
+    private function addProfessions(Job &$job,$terms)
304
+    {
305
+        $professions = $this->getCategories($terms);
306
+        foreach($professions as $profession){
307
+            $values = $job->getClassifications()->getProfessions()->getValues();
308
+            if(!is_array($values) || !in_array($profession,$values)){
309
+                $job->getClassifications()->getProfessions()->getItems()->add($profession);
310
+            }
311
+        }
312
+    }
313 313
 	
314
-	private function addIndustries(Job &$job, $terms)
315
-	{
316
-		$industries = $this->getCategories($terms);
317
-		foreach($industries as $industry){
318
-			$values = $job->getClassifications()->getIndustries()->getValues();
319
-			if(!is_array($values) || !in_array($industry,$values)){
320
-				$job->getClassifications()->getIndustries()->getItems()->add($industry);
321
-			}
322
-		}
323
-	}
314
+    private function addIndustries(Job &$job, $terms)
315
+    {
316
+        $industries = $this->getCategories($terms);
317
+        foreach($industries as $industry){
318
+            $values = $job->getClassifications()->getIndustries()->getValues();
319
+            if(!is_array($values) || !in_array($industry,$values)){
320
+                $job->getClassifications()->getIndustries()->getItems()->add($industry);
321
+            }
322
+        }
323
+    }
324 324
 	
325
-	/**
326
-	 * @param array $categories
327
-	 *
328
-	 * @return mixed
329
-	 */
330
-	private function getCategories(array $categories)
331
-	{
332
-		$catRepo = $this->getCategoriesRepository();
325
+    /**
326
+     * @param array $categories
327
+     *
328
+     * @return mixed
329
+     */
330
+    private function getCategories(array $categories)
331
+    {
332
+        $catRepo = $this->getCategoriesRepository();
333 333
 		
334
-		// get a professions
335
-		$qb = $catRepo->createQueryBuilder()
336
-		              ->field('name')->in($categories)
337
-		              ->getQuery()
338
-		;
339
-		$results = $qb->execute();
340
-		return $results->toArray();
341
-	}
334
+        // get a professions
335
+        $qb = $catRepo->createQueryBuilder()
336
+                        ->field('name')->in($categories)
337
+                        ->getQuery()
338
+        ;
339
+        $results = $qb->execute();
340
+        return $results->toArray();
341
+    }
342 342
 	
343 343
 	
344
-	/**
345
-	 * @return Job
346
-	 */
347
-	private function getCurrentUserJobDraft($jobTitle)
348
-	{
349
-		$repo = $this->getJobRepository();
350
-		$user = $this->getCurrentUser();
344
+    /**
345
+     * @return Job
346
+     */
347
+    private function getCurrentUserJobDraft($jobTitle)
348
+    {
349
+        $repo = $this->getJobRepository();
350
+        $user = $this->getCurrentUser();
351 351
 		
352
-		$job = $repo->findDraft($user);
352
+        $job = $repo->findDraft($user);
353 353
 		
354
-		if(is_null($job)){
355
-			$job = new Job();
356
-			$job
357
-				->setUser($user)
358
-				->setOrganization($user->getOrganization()->getOrganization())
359
-				->setStatus(StatusInterface::CREATED)
360
-			;
361
-			$job->setIsDraft(true);
362
-		}
363
-		$job->setTitle($jobTitle);
364
-		$repo->store($job);
365
-		return $job;
366
-	}
354
+        if(is_null($job)){
355
+            $job = new Job();
356
+            $job
357
+                ->setUser($user)
358
+                ->setOrganization($user->getOrganization()->getOrganization())
359
+                ->setStatus(StatusInterface::CREATED)
360
+            ;
361
+            $job->setIsDraft(true);
362
+        }
363
+        $job->setTitle($jobTitle);
364
+        $repo->store($job);
365
+        return $job;
366
+    }
367 367
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	{
59 59
 		$repo = static::$jobRepo;
60 60
 		$results = $repo->findBy(['user' => $user]);
61
-		foreach($results as $result){
62
-			$repo->remove($result,true);
61
+		foreach ($results as $result) {
62
+			$repo->remove($result, true);
63 63
 		}
64 64
 	}
65 65
 	
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	public function beforeScenario(BeforeScenarioScope $scope)
72 72
 	{
73 73
 		$this->select2Context = $scope->getEnvironment()->getContext(Select2Context::class);
74
-		if(is_null(static::$jobRepo)){
74
+		if (is_null(static::$jobRepo)) {
75 75
 			$this->gatherContexts($scope);
76 76
 			static::$jobRepo = $this->getJobRepository();
77 77
 		}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function iGoToCreateJob()
92 92
 	{
93
-	    $url = $this->buildUrl('lang/jobs/manage',['action' => 'edit']);
93
+	    $url = $this->buildUrl('lang/jobs/manage', ['action' => 'edit']);
94 94
 		$this->visit($url);
95 95
 	}
96 96
 	
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 	public function iGoToEditJobWithTitle($jobTitle)
111 111
 	{
112 112
 		$job = $this->getJobRepository()->findOneBy(['title' => $jobTitle]);
113
-		if(!$job instanceof Job){
114
-			throw new \Exception(sprintf('Job with title "%s" is not found',$jobTitle));
113
+		if (!$job instanceof Job) {
114
+			throw new \Exception(sprintf('Job with title "%s" is not found', $jobTitle));
115 115
 		}
116 116
 		$this->currentJob = $job;
117
-		$url = $this->buildUrl('lang/jobs/manage',[
117
+		$url = $this->buildUrl('lang/jobs/manage', [
118 118
 		    'id' => $job->getId()
119 119
         ]);
120 120
 		$this->visit($url);
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 
141 141
 		$jobRepository = $this->getJobRepository();
142 142
 		$results = $jobRepository->getUserJobs($user->getId());
143
-		foreach($results as $job){
144
-			$jobRepository->remove($job,true);
143
+		foreach ($results as $job) {
144
+			$jobRepository->remove($job, true);
145 145
 		}
146 146
 		$this->currentJob = null;
147 147
 	}
@@ -150,16 +150,16 @@  discard block
 block discarded – undo
150 150
 	 * @When I fill job location search with :search and choose :choice
151 151
 	 *
152 152
 	 */
153
-	public function iFillJobLocationAndChoose($search,$choice)
153
+	public function iFillJobLocationAndChoose($search, $choice)
154 154
 	{
155 155
 		$select2 = $this->select2Context;
156
-		$select2->iFillInSelect2FieldWith('jobBase[geoLocation]',$search,$choice);
156
+		$select2->iFillInSelect2FieldWith('jobBase[geoLocation]', $search, $choice);
157 157
 	}
158 158
 	
159 159
 	/**
160 160
 	 * @When I choose :value from :field
161 161
 	 */
162
-	public function iJobClassificationSelect($value,$field)
162
+	public function iJobClassificationSelect($value, $field)
163 163
 	{
164 164
 		$field = Inflector::camelize($field);
165 165
 		
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
 			'employmentTypes'    => "select#classifications-employmentTypes",
176 176
 		];
177 177
 		
178
-		if(!isset($mapSelect2[$field])){
178
+		if (!isset($mapSelect2[$field])) {
179 179
 			throw new \Exception('Undefined field selection value "'.$field.'"');
180 180
 		}
181 181
 		
182 182
 		$multipleField = $mapMultiple[$field];
183 183
 		$page = $this->minkContext->getSession()->getPage();
184
-		$element = $page->find('css',$mapMultiple[$field]);
185
-		if(!is_null($element) && $element->getAttribute('multiple')=='multiple'){
186
-			$this->minkContext->selectOption($value,$multipleField);
187
-		}else{
184
+		$element = $page->find('css', $mapMultiple[$field]);
185
+		if (!is_null($element) && $element->getAttribute('multiple') == 'multiple') {
186
+			$this->minkContext->selectOption($value, $multipleField);
187
+		} else {
188 188
 			$locator = $mapSelect2[$field];
189
-			$this->select2Context->iFillInSelect2Field($locator,$value);
189
+			$this->select2Context->iFillInSelect2Field($locator, $value);
190 190
 		}
191 191
 	}
192 192
 	
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
 	 * @When I have a :status job with the following:
211 211
 	 * @param TableNode $fields
212 212
 	 */
213
-	public function iHaveAJobWithTheFollowing($status,TableNode $fields)
213
+	public function iHaveAJobWithTheFollowing($status, TableNode $fields)
214 214
 	{
215
-		$this->buildJob($status,$fields->getRowsHash());
215
+		$this->buildJob($status, $fields->getRowsHash());
216 216
 	}
217 217
 
218
-	public function buildJob($status, $definitions,$organization = null)
218
+	public function buildJob($status, $definitions, $organization = null)
219 219
     {
220 220
         $normalizedField = [
221 221
             'template' => 'modern',
222 222
         ];
223
-        foreach($definitions as $field => $value){
223
+        foreach ($definitions as $field => $value) {
224 224
             $field = Inflector::camelize($field);
225
-            if($field == 'professions' || $field == 'industries'){
226
-                $value = explode(',',$value);
225
+            if ($field == 'professions' || $field == 'industries') {
226
+                $value = explode(',', $value);
227 227
             }
228 228
             $normalizedField[$field] = $value;
229 229
         }
@@ -232,49 +232,49 @@  discard block
 block discarded – undo
232 232
         $job = $jobRepo->findOneBy([
233 233
             'title' => $normalizedField['title']
234 234
         ]);
235
-        if(!$job instanceof Job){
235
+        if (!$job instanceof Job) {
236 236
             $job = new Job();
237 237
             $job->setTitle($normalizedField['title']);
238 238
         }
239 239
 
240
-        if(isset($normalizedField['user'])){
240
+        if (isset($normalizedField['user'])) {
241 241
             /* @var $userRepo UserRepository */
242 242
             $userRepo = $this->getRepository('Auth\Entity\User');
243 243
             $user = $userRepo->findOneBy(['login' => $normalizedField['user']]);
244
-            if(is_null($organization)){
244
+            if (is_null($organization)) {
245 245
                 $organization = $user->getOrganization()->getOrganization();
246 246
             }
247
-            if($user instanceof User){
247
+            if ($user instanceof User) {
248 248
                 $job->setUser($user);
249 249
                 $job->setOrganization($organization);
250
-            }else{
250
+            } else {
251 251
                 throw new \Exception('There is no user with this login:"'.$normalizedField['user'.'"']);
252 252
             }
253 253
         }
254 254
 
255
-        if($status == 'draft'){
255
+        if ($status == 'draft') {
256 256
             $job->setIsDraft(true);
257
-        }elseif($status == 'published'){
257
+        }elseif ($status == 'published') {
258 258
             $job->setIsDraft(false);
259 259
             $job->setDatePublishStart(new \DateTime());
260 260
         }
261 261
         $job->setStatus(Status::ACTIVE);
262 262
 
263
-        if(isset($normalizedField['location'])){
264
-            $this->setLocation($job,$normalizedField['location']);
263
+        if (isset($normalizedField['location'])) {
264
+            $this->setLocation($job, $normalizedField['location']);
265 265
         }
266
-        if(isset($normalizedField['professions'])){
267
-            $this->addProfessions($job,$normalizedField['professions']);
266
+        if (isset($normalizedField['professions'])) {
267
+            $this->addProfessions($job, $normalizedField['professions']);
268 268
         }
269 269
 
270
-        if(isset($normalizedField['industries'])){
271
-            $this->addIndustries($job,$normalizedField['industries']);
270
+        if (isset($normalizedField['industries'])) {
271
+            $this->addIndustries($job, $normalizedField['industries']);
272 272
         }
273
-        if(isset($normalizedField['employmentTypes'])){
273
+        if (isset($normalizedField['employmentTypes'])) {
274 274
             $types = $this->getCategories([$normalizedField['employmentTypes']]);
275 275
             $type = array_shift($types);
276 276
             $values = $job->getClassifications()->getEmploymentTypes()->getValues();
277
-            if(!is_array($values) || !in_array($type,$values)){
277
+            if (!is_array($values) || !in_array($type, $values)) {
278 278
                 $job->getClassifications()->getEmploymentTypes()->getItems()->add($type);
279 279
             }
280 280
         }
@@ -294,18 +294,18 @@  discard block
 block discarded – undo
294 294
 		$location->fromString($serialized);
295 295
 		
296 296
 		$locations = $job->getLocations();
297
-		if(count($locations)){
297
+		if (count($locations)) {
298 298
 			$locations->clear();
299 299
 		}
300 300
 		$job->getLocations()->add($location);
301 301
 	}
302 302
 	
303
-	private function addProfessions(Job &$job,$terms)
303
+	private function addProfessions(Job &$job, $terms)
304 304
 	{
305 305
 		$professions = $this->getCategories($terms);
306
-		foreach($professions as $profession){
306
+		foreach ($professions as $profession) {
307 307
 			$values = $job->getClassifications()->getProfessions()->getValues();
308
-			if(!is_array($values) || !in_array($profession,$values)){
308
+			if (!is_array($values) || !in_array($profession, $values)) {
309 309
 				$job->getClassifications()->getProfessions()->getItems()->add($profession);
310 310
 			}
311 311
 		}
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 	private function addIndustries(Job &$job, $terms)
315 315
 	{
316 316
 		$industries = $this->getCategories($terms);
317
-		foreach($industries as $industry){
317
+		foreach ($industries as $industry) {
318 318
 			$values = $job->getClassifications()->getIndustries()->getValues();
319
-			if(!is_array($values) || !in_array($industry,$values)){
319
+			if (!is_array($values) || !in_array($industry, $values)) {
320 320
 				$job->getClassifications()->getIndustries()->getItems()->add($industry);
321 321
 			}
322 322
 		}
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 		
352 352
 		$job = $repo->findDraft($user);
353 353
 		
354
-		if(is_null($job)){
354
+		if (is_null($job)) {
355 355
 			$job = new Job();
356 356
 			$job
357 357
 				->setUser($user)
Please login to merge, or discard this patch.
module/Organizations/src/Organizations/Entity/Organization.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,17 +47,17 @@  discard block
 block discarded – undo
47 47
     /**
48 48
      * Always enabled even if there are no active jobs
49 49
      */
50
-    const PROFILE_ALWAYS_ENABLE     = 'always';
50
+    const PROFILE_ALWAYS_ENABLE = 'always';
51 51
 
52 52
     /**
53 53
      * Hide if there are no jobs available
54 54
      */
55
-    const PROFILE_ACTIVE_JOBS       = 'active-jobs';
55
+    const PROFILE_ACTIVE_JOBS = 'active-jobs';
56 56
 
57 57
     /**
58 58
      * Always disabled profile
59 59
      */
60
-    const PROFILE_DISABLED          = 'disabled';
60
+    const PROFILE_DISABLED = 'disabled';
61 61
 
62 62
     /**
63 63
      * Event name of post construct event.
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      */
286 286
     public function getParent($returnSelf = false)
287 287
     {
288
-        return $this->parent ? : ($returnSelf ? $this : null);
288
+        return $this->parent ?: ($returnSelf ? $this : null);
289 289
     }
290 290
 
291 291
     /**
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
      */
517 517
     public function getPermissionsResourceId()
518 518
     {
519
-        return 'organization:' . $this->getId();
519
+        return 'organization:'.$this->getId();
520 520
     }
521 521
 
522 522
     /**
Please login to merge, or discard this patch.
Organizations/src/Organizations/Form/OrganizationsProfileFieldset.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
     public function getHydrator()
25 25
     {
26 26
         if (!$this->hydrator) {
27
-            $hydrator           = new EntityHydrator();
27
+            $hydrator = new EntityHydrator();
28 28
             $this->setHydrator($hydrator);
29 29
         }
30 30
         return $this->hydrator;
Please login to merge, or discard this patch.