public function getSessionEventRemainingPlaces(SessionEvent $sessionEvent) { $remainingPlaces = null; $maxUsers = $sessionEvent->getMaxUsers(); if (!is_null($maxUsers)) { $remainingPlaces = $maxUsers; $eventUsers = $sessionEvent->getSessionEventUsers(); foreach ($eventUsers as $eventUser) { if ($eventUser->getRegistrationStatus() === SessionEventUser::REGISTERED) { --$remainingPlaces; } } } return $remainingPlaces; }