Skip to content

Commit 5ca1ce9

Browse files
dinamicdkarlovi
authored andcommitted
~ slightly refactored AuthorizeFormHandler
1 parent 1115345 commit 5ca1ce9

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

Form/Handler/AuthorizeFormHandler.php

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,34 @@ public function isRejected()
7171
return !$this->form->getData()->accepted;
7272
}
7373

74+
/**
75+
* @return bool|void
76+
*/
7477
public function process()
7578
{
7679
$request = $this->getCurrentRequest();
77-
if (null !== $request) {
78-
$this->form->setData(new Authorize(
79-
$request->request->has('accepted'),
80-
$request->query->all()
81-
));
82-
83-
if ('POST' === $request->getMethod()) {
84-
$this->form->handleRequest($request);
85-
if ($this->form->isValid()) {
86-
$this->onSuccess();
87-
88-
return true;
89-
}
90-
}
80+
81+
if (null === $request) {
82+
return false;
83+
}
84+
85+
$this->form->setData(new Authorize(
86+
$request->request->has('accepted'),
87+
$request->query->all()
88+
));
89+
90+
if ('POST' !== $request->getMethod()) {
91+
return;
9192
}
9293

93-
return false;
94+
$this->form->handleRequest($request);
95+
if (!$this->form->isValid()) {
96+
return;
97+
}
98+
99+
$this->onSuccess();
100+
101+
return true;
94102
}
95103

96104
public function getScope()
@@ -126,14 +134,14 @@ protected function onSuccess()
126134

127135
private function getCurrentRequest()
128136
{
129-
if (null !== $this->requestStack) {
130-
if ($this->requestStack instanceof Request) {
131-
return $this->requestStack;
132-
} else {
133-
return $this->requestStack->getCurrentRequest();
134-
}
137+
if (null === $this->requestStack) {
138+
return $this->container->get('request');
139+
}
140+
141+
if ($this->requestStack instanceof Request) {
142+
return $this->requestStack;
135143
}
136144

137-
return $this->container->get('request');
145+
return $this->requestStack->getCurrentRequest();
138146
}
139147
}

0 commit comments

Comments
 (0)