class RegistrationAddAccessCheck in RNG - Events and Registrations 8.2
Same name and namespace in other branches
- 8 src/Access/RegistrationAddAccessCheck.php \Drupal\rng\Access\RegistrationAddAccessCheck
- 3.x src/Access/RegistrationAddAccessCheck.php \Drupal\rng\Access\RegistrationAddAccessCheck
Checks new registrations are permitted on an event.
Hierarchy
- class \Drupal\rng\Access\RegistrationAddAccessCheck implements AccessInterface
Expanded class hierarchy of RegistrationAddAccessCheck
1 string reference to 'RegistrationAddAccessCheck'
1 service uses RegistrationAddAccessCheck
File
- src/Access/ RegistrationAddAccessCheck.php, line 16 
Namespace
Drupal\rng\AccessView source
class RegistrationAddAccessCheck implements AccessInterface {
  /**
   * The entity manager.
   *
   * @var \Drupal\Core\Entity\EntityManagerInterface
   */
  protected $entityManager;
  /**
   * Constructs a EventRegistrationAllowedCheck object.
   *
   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
   *   The entity manager.
   */
  public function __construct(EntityManagerInterface $entity_manager) {
    $this->entityManager = $entity_manager;
  }
  /**
   * Checks new registrations are permitted on an event.
   */
  public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account, RegistrationTypeInterface $registration_type = NULL) {
    if ($event = $route
      ->getDefault('event')) {
      $context = [
        'event' => $route_match
          ->getParameter($event),
      ];
      $access_control_handler = $this->entityManager
        ->getAccessControlHandler('registration');
      if ($registration_type) {
        return $access_control_handler
          ->createAccess($registration_type
          ->id(), $account, $context, TRUE);
      }
      else {
        return $access_control_handler
          ->createAccess(NULL, $account, $context, TRUE);
      }
    }
    return AccessResult::forbidden();
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| RegistrationAddAccessCheck:: | protected | property | The entity manager. | |
| RegistrationAddAccessCheck:: | public | function | Checks new registrations are permitted on an event. | |
| RegistrationAddAccessCheck:: | public | function | Constructs a EventRegistrationAllowedCheck object. | 
