/**
  * Creates and saves a registration entity.
  *
  * @param \Drupal\Core\Entity\ContentEntityInterface $event
  *   An event entity.
  * @param string $registration_type_id
  *   A registration type ID.
  *
  * @return \Drupal\rng\Entity\Registration
  *   A saved registration entity.
  */
 function createRegistration(ContentEntityInterface $event, $registration_type_id)
 {
     $registration = Registration::create(['type' => $registration_type_id])->setEvent($event);
     $registration->save();
     return $registration;
 }
 /**
  * Provides a registration form.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The matched route.
  *
  * @param string $event
  *   The parameter to find the event entity.
  *
  * @param \Drupal\rng\RegistrationTypeInterface $registration_type
  *   The type of registration.
  *
  * @return array A registration form.
  */
 public function RegistrationAdd(RouteMatchInterface $route_match, $event, RegistrationTypeInterface $registration_type)
 {
     $event_entity = $route_match->getParameter($event);
     $registration = Registration::create(['type' => $registration_type->id()]);
     $registration->setEvent($event_entity);
     return $this->entityFormBuilder()->getForm($registration, 'add', array($event_entity));
 }