-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split procuration manager in five tabs. #876
Conversation
2890c88
to
33670e7
Compare
This probably need more work as we introduced filters in #881 |
I'll finish this PR tomorrow morning ;) |
$requestsRepository = $this->getDoctrine()->getRepository(ProcurationRequest::class); | ||
$requests = $requestsRepository->findManagedBy($this->getUser(), (int) $page, self::PER_PAGE); | ||
try { | ||
$requests = $this->get('app.procuration.manager')->getProcurationRequests(strtolower($request->query->get('type', 'unprocessed')), self::PER_PAGE, (int) $page); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The int casting should be a parameter type hint in the signature (it will also cast).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes right!
@@ -157,29 +161,25 @@ public function requestAction(ProcurationRequest $request): Response | |||
* ) | |||
* @Method("GET") | |||
*/ | |||
public function requestTransformAction(ProcurationRequest $request, $action, $token): Response | |||
public function requestTransformAction($id, $action, $token): Response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add parameters type hint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
{ | ||
if (!$this->get('security.csrf.token_manager')->isTokenValid(new CsrfToken('request_action', $token))) { | ||
if (!$this->isCsrfTokenValid('request_action', $token)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request_action
should better be a constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's only used here as far as I know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And twig
|
||
private static function ensureProcessingType(string $type): void | ||
{ | ||
if (!in_array($type, ['processed', 'unprocessed'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use constants for types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep I thought about that.
e1a45e9
to
98555e7
Compare
94fb261
to
338ef45
Compare
-- | ||
<a href="{{ path('app_procuration_manager_index', {'status': 'processed'}) }}">Mandants traités</a> | ||
-- | ||
<a href="{{ path('app_procuration_manager_proposals') }}">Mandataires traités</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same path for the processed and unprocessed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups I forgot to implement the status filtering for proxy proposals.
return; | ||
} | ||
|
||
if (!in_array($country, array_keys($this->getCountries()))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing third parameter ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes good catch.
parent::apply($qb, $alias); | ||
|
||
$qb | ||
->addOrderBy('pp.createdAt', 'DESC') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can use $alias (if it contains 'pp') ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to! Thanks!
'total_count' => $manager->countProcurationProxyProposals($this->getUser(), $filters), | ||
'filters' => $filters, | ||
]); | ||
} catch (ProcurationException $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole try block is necessary ? (I know it's changes nothing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes to convert ProcurationException
exceptions into BadRequestHttpException
exceptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant ProcurationException
is only throw from the method fromQueryString
right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes right.
|
||
private $status = self::UNPROCESSED; | ||
|
||
public static function fromQueryString(Request $request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing return type hint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impossible here. Because of the new static()
in the parent class. We can't typehint against static
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
338ef45
to
9a3f8d1
Compare
8d25293
to
ec7a9d3
Compare
{% endif %} | ||
{% if 0 == proxies|length %} | ||
<div class="text--body text--center"> | ||
{% if constant('AppBundle\\Procuration\\Filter\\ProcurationProxyProposalFilters::UNASSOCIATED') == filters.status %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the variable filters
is an instance of ProcurationProxyProposalFilters
you can use it to do constant('UNASSOCIATED', filters)
And all constant in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes excellent thanks.
|
||
{% if 0 == requests|length %} | ||
<div class="text--body text--center"> | ||
{% if constant('AppBundle\\Procuration\\Filter\\ProcurationRequestFilters::PROCESSED') == filters.status %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use filters here too I guess.
} | ||
|
||
$qb | ||
->setFirstResult(($this->currentPage - 1) * $this->getLimit()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO the method getLimit
is useless. You should use the constant directly here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True!
ec7a9d3
to
e54f13e
Compare
@mykiwi all requested changes have been applied ;) |
e54f13e
to
1ca33e3
Compare
1ca33e3
to
af4909a
Compare
throw new ProcurationException(sprintf('Invalid country filter value given ("%s").', $country)); | ||
} | ||
|
||
$this->country = trim($country); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a second trim?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be truly sure it's trimmed ^^
It must be removed for sure.
{ | ||
parent::apply($qb, $alias); | ||
|
||
$status = $this->getStatus(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use a switch to evaluate only once without storing it in a variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate switch() statements, they make the code less readable IMO.
{ | ||
parent::apply($qb, $alias); | ||
|
||
if (self::UNPROCESSED === $this->getStatus()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, it would be more readable with both cases explicit.
No description provided.