getUser()) { return true; } // Only users with administrative role may edit assignments if (static::EDIT === $attribute) { return $this->security->isGranted('ROLE_ADMINISTRATIVE'); } // Only allow applications to published assignments if (Assignment::STATUS_DRAFT === $assignment->getStatus()) { return false; } // Only allow applications on empty slots $availableSlots = (int) $assignment->getAvailableDispositions(); if (0 < $availableSlots) { $dispositions = $this ->entityManager ->getRepository(Disposition::class) ->findCurrentDispositionsByAssignment($assignment) ; return count($dispositions) < $availableSlots; } // Only teamers without existing applications may apply to the assignment if ($this->security->isGranted('ROLE_TEAMER')) { /** @var User $user */ $user = $token->getUser(); $teamer = $user->getTeamer(); $application = $this ->entityManager ->getRepository(Application::class) ->findOneBy(['teamer' => $teamer, 'assignment' => $assignment]); return null === $application; } return false; } }