Sort collection of participations by firstname in Event entity

This commit is contained in:
Tchama 2019-10-21 13:04:22 +02:00
parent 7ac7def366
commit 8275715b56

View File

@ -4,7 +4,6 @@ namespace Chill\EventBundle\Entity;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\HasScopeInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* Event
@ -215,11 +214,28 @@ class Event implements HasCenterInterface, HasScopeInterface
/**
* Get participations
*
* @return \Doctrine\Common\Collections\Collection
* @return \ArrayIterator|\Doctrine\Common\Collections\Collection|\Traversable
*/
public function getParticipations()
{
return $this->participations;
return $this->getParticipationsOrdered();
}
/**
* Sort Collection of Participations
*
* @return \ArrayIterator|\Traversable
*/
public function getParticipationsOrdered() {
$iterator = $this->participations->getIterator();
$iterator->uasort(function($first, $second)
{
return strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName());
});
return $iterator;
}
/**