You are here

class EnrollInviteUserForm in Open Social 8.9

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteUserForm.php \Drupal\social_event_invite\Form\EnrollInviteUserForm
  2. 10.0.x modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteUserForm.php \Drupal\social_event_invite\Form\EnrollInviteUserForm
  3. 10.1.x modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteUserForm.php \Drupal\social_event_invite\Form\EnrollInviteUserForm
  4. 10.2.x modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteUserForm.php \Drupal\social_event_invite\Form\EnrollInviteUserForm

Class EnrollInviteForm.

Hierarchy

Expanded class hierarchy of EnrollInviteUserForm

1 string reference to 'EnrollInviteUserForm'
social_event_invite.routing.yml in modules/social_features/social_event/modules/social_event_invite/social_event_invite.routing.yml
modules/social_features/social_event/modules/social_event_invite/social_event_invite.routing.yml

File

modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteUserForm.php, line 17

Namespace

Drupal\social_event_invite\Form
View source
class EnrollInviteUserForm extends InviteUserBaseForm {

  /**
   * The event invite status helper.
   *
   * @var \Drupal\social_event\EventEnrollmentStatusHelper
   */
  protected $eventInviteStatus;

  /**
   * Drupal\Core\TempStore\PrivateTempStoreFactory definition.
   *
   * @var \Drupal\Core\TempStore\PrivateTempStoreFactory
   */
  private $tempStoreFactory;

  /**
   * {@inheritdoc}
   */
  public function __construct(RouteMatchInterface $route_match, EntityTypeManagerInterface $entity_type_manager, LoggerChannelFactoryInterface $logger_factory, EventEnrollmentStatusHelper $eventInviteStatus, PrivateTempStoreFactory $tempStoreFactory) {
    parent::__construct($route_match, $entity_type_manager, $logger_factory);
    $this->eventInviteStatus = $eventInviteStatus;
    $this->tempStoreFactory = $tempStoreFactory;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('current_route_match'), $container
      ->get('entity_type.manager'), $container
      ->get('logger.factory'), $container
      ->get('social_event.status_helper'), $container
      ->get('tempstore.private'));
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'enroll_invite_user_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form, $form_state);
    $nid = $this->routeMatch
      ->getRawParameter('node');
    $form['event'] = [
      '#type' => 'hidden',
      '#value' => $nid,
    ];
    $form['name'] = [
      '#type' => 'social_enrollment_entity_autocomplete',
      '#selection_handler' => 'social',
      '#selection_settings' => [],
      '#target_type' => 'user',
      '#tags' => TRUE,
      '#description' => $this
        ->t('To add multiple members, separate each member with a comma ( , ).'),
      '#title' => $this
        ->t('Select members to add by name or email address'),
      '#weight' => -1,
    ];
    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this
        ->t('Save'),
    ];
    $form['actions']['submit_cancel'] = [
      '#type' => 'submit',
      '#weight' => 999,
      '#value' => $this
        ->t('Back to event'),
      '#submit' => [
        [
          $this,
          'cancelForm',
        ],
      ],
      '#limit_validation_errors' => [],
    ];
    return $form;
  }

  /**
   * Cancel form taking you back to an event.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   */
  public function cancelForm(array &$form, FormStateInterface $form_state) {
    $form_state
      ->setRedirect('view.event_manage_enrollments.page_manage_enrollments', [
      'node' => $this->routeMatch
        ->getRawParameter('node'),
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    $params['recipients'] = $form_state
      ->getValue('entity_id_new');
    $params['nid'] = $form_state
      ->getValue('event');
    $tempstore = $this->tempStoreFactory
      ->get('event_invite_form_values');
    try {
      $tempstore
        ->set('params', $params);
      $form_state
        ->setRedirect('social_event_invite.confirm_invite', [
        'node' => $form_state
          ->getValue('event'),
      ]);
    } catch (\Exception $error) {
      $this->loggerFactory
        ->get('event_invite_form_values')
        ->alert(t('@err', [
        '@err' => $error,
      ]));
      $this->messenger
        ->addWarning(t('Unable to proceed, please try again.'));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EnrollInviteUserForm::$eventInviteStatus protected property The event invite status helper.
EnrollInviteUserForm::$tempStoreFactory private property Drupal\Core\TempStore\PrivateTempStoreFactory definition.
EnrollInviteUserForm::buildForm public function Form constructor. Overrides InviteUserBaseForm::buildForm
EnrollInviteUserForm::cancelForm public function Cancel form taking you back to an event.
EnrollInviteUserForm::create public static function Instantiates a new instance of this class. Overrides InviteUserBaseForm::create
EnrollInviteUserForm::getFormId public function Returns a unique string identifying the form. Overrides InviteUserBaseForm::getFormId
EnrollInviteUserForm::submitForm public function Form submission handler. Overrides InviteUserBaseForm::submitForm
EnrollInviteUserForm::__construct public function Constructs a new BulkGroupInvitation Form. Overrides InviteUserBaseForm::__construct
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::config protected function Retrieves a configuration object.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 62
InviteUserBaseForm::$entityTypeManager protected property The entity type manager.
InviteUserBaseForm::$loggerFactory protected property The logger factory. Overrides LoggerChannelTrait::$loggerFactory
InviteUserBaseForm::$routeMatch protected property The route match. Overrides FormBase::$routeMatch
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.