mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
improve histories order since User entity
This commit is contained in:
parent
c526973475
commit
0b6b25fd95
@ -28,16 +28,18 @@ class UserJobScopeHistoriesController extends AbstractController
|
||||
*/
|
||||
public function indexAction(User $user): Response
|
||||
{
|
||||
$jobHistories = $user->getUserJobHistories();
|
||||
$scopeHistories = $user->getMainScopeHistories();
|
||||
|
||||
$jobHistories = $user->getUserJobHistoriesOrdered();
|
||||
$scopeHistories = $user->getMainScopeHistoriesOrdered();
|
||||
|
||||
return new Response(
|
||||
$this->engine->render('@ChillMain/User/history.html.twig', [
|
||||
$this->engine->render(
|
||||
'@ChillMain/User/history.html.twig',
|
||||
[
|
||||
'user' => $user,
|
||||
'jobHistories' => $jobHistories,
|
||||
'scopeHistories' => $scopeHistories,
|
||||
]
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -283,6 +283,22 @@ class User implements UserInterface, \Stringable
|
||||
return $this->scopeHistories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection|UserScopeHistory[]
|
||||
*/
|
||||
public function getMainScopeHistoriesOrdered(): ArrayCollection
|
||||
{
|
||||
$scopeHistories = $this->getMainScopeHistories();
|
||||
|
||||
$sortedScopeHistories = $scopeHistories->toArray();
|
||||
|
||||
usort($sortedScopeHistories, function ($a, $b) {
|
||||
return $a->getStartDate() < $b->getStartDate() ? 1 : -1;
|
||||
});
|
||||
|
||||
return new ArrayCollection($sortedScopeHistories);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -321,6 +337,22 @@ class User implements UserInterface, \Stringable
|
||||
return $this->jobHistories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection|UserJobHistory[]
|
||||
*/
|
||||
public function getUserJobHistoriesOrdered(): ArrayCollection
|
||||
{
|
||||
$jobHistories = $this->getUserJobHistories();
|
||||
|
||||
$sortedJobHistories = $jobHistories->toArray();
|
||||
|
||||
usort($sortedJobHistories, function ($a, $b) {
|
||||
return $a->getStartDate() < $b->getStartDate() ? 1 : -1;
|
||||
});
|
||||
|
||||
return new ArrayCollection($sortedJobHistories);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -16,7 +16,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entity in jobHistories|reverse %}
|
||||
{% for entity in jobHistories %}
|
||||
<tr>
|
||||
<td>{{ entity.startDate|format_datetime('medium') }}</td>
|
||||
<td>
|
||||
@ -48,7 +48,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entity in scopeHistories|reverse %}
|
||||
{% for entity in scopeHistories %}
|
||||
<tr>
|
||||
<td>{{ entity.startDate|format_datetime('medium') }}</td>
|
||||
<td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user