mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
improve histories order since User entity
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user