You are here

class RegistrationSubscriber in RNG - Events and Registrations 3.x

Class RegistrationSubscriber.

Hierarchy

  • class \Drupal\rng_easy_email\EventSubscriber\RegistrationSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of RegistrationSubscriber

1 string reference to 'RegistrationSubscriber'
rng_easy_email.services.yml in rng_easy_email/rng_easy_email.services.yml
rng_easy_email/rng_easy_email.services.yml
1 service uses RegistrationSubscriber
rng_easy_email.sender in rng_easy_email/rng_easy_email.services.yml
Drupal\rng_easy_email\EventSubscriber\RegistrationSubscriber

File

rng_easy_email/src/EventSubscriber/RegistrationSubscriber.php, line 15

Namespace

Drupal\rng_easy_email\EventSubscriber
View source
class RegistrationSubscriber implements EventSubscriberInterface {

  /**
   * Drupal\rng\EventManagerInterface definition.
   *
   * @var \Drupal\rng\EventManagerInterface
   */
  protected $rngEventManager;

  /**
   * Drupal\Core\Entity\EntityTypeManagerInterface definition.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Dispatch Service.
   *
   * @var \Drupal\rng_easy_email\DispatchService
   */
  protected $dispatchService;

  /**
   * Constructs a new RegistrationSubscriber object.
   */
  public function __construct(EventManagerInterface $rng_event_manager, EntityTypeManagerInterface $entity_type_manager, DispatchService $dispatchService) {
    $this->rngEventManager = $rng_event_manager;
    $this->entityTypeManager = $entity_type_manager;
    $this->dispatchService = $dispatchService;
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events['rng.registration.insert'] = [
      'RegistrationSend',
    ];
    $events['rng.registration.registration'] = [
      'RegistrationSend',
    ];
    return $events;
  }

  /**
   * This method is called when the rng.registration.insert is dispatched.
   * This method is called when the rng.registration.registration is dispatched.
   *
   * @param RegistrationEvent $event
   *   The dispatched event.
   */
  public function RegistrationSend(RegistrationEvent $event) {
    $registration = $event
      ->getRegistration();
    if ($registration
      ->isConfirmed()) {
      $this->dispatchService
        ->sendRegistration('attendee_registered', $registration);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RegistrationSubscriber::$dispatchService protected property Dispatch Service.
RegistrationSubscriber::$entityTypeManager protected property Drupal\Core\Entity\EntityTypeManagerInterface definition.
RegistrationSubscriber::$rngEventManager protected property Drupal\rng\EventManagerInterface definition.
RegistrationSubscriber::getSubscribedEvents public static function
RegistrationSubscriber::RegistrationSend public function This method is called when the rng.registration.insert is dispatched. This method is called when the rng.registration.registration is dispatched.
RegistrationSubscriber::__construct public function Constructs a new RegistrationSubscriber object.