class EnrollInviteUserForm in Open Social 8.9
Same name and namespace in other branches
- 10.3.x modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteUserForm.php \Drupal\social_event_invite\Form\EnrollInviteUserForm
- 10.0.x modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteUserForm.php \Drupal\social_event_invite\Form\EnrollInviteUserForm
- 10.1.x modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteUserForm.php \Drupal\social_event_invite\Form\EnrollInviteUserForm
- 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
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\social_core\Form\InviteUserBaseForm
- class \Drupal\social_event_invite\Form\EnrollInviteUserForm
- class \Drupal\social_core\Form\InviteUserBaseForm
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\FormView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
EnrollInviteUserForm:: |
protected | property | The event invite status helper. | |
EnrollInviteUserForm:: |
private | property | Drupal\Core\TempStore\PrivateTempStoreFactory definition. | |
EnrollInviteUserForm:: |
public | function |
Form constructor. Overrides InviteUserBaseForm:: |
|
EnrollInviteUserForm:: |
public | function | Cancel form taking you back to an event. | |
EnrollInviteUserForm:: |
public static | function |
Instantiates a new instance of this class. Overrides InviteUserBaseForm:: |
|
EnrollInviteUserForm:: |
public | function |
Returns a unique string identifying the form. Overrides InviteUserBaseForm:: |
|
EnrollInviteUserForm:: |
public | function |
Form submission handler. Overrides InviteUserBaseForm:: |
|
EnrollInviteUserForm:: |
public | function |
Constructs a new BulkGroupInvitation Form. Overrides InviteUserBaseForm:: |
|
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | function | Retrieves a configuration object. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
InviteUserBaseForm:: |
protected | property | The entity type manager. | |
InviteUserBaseForm:: |
protected | property |
The logger factory. Overrides LoggerChannelTrait:: |
|
InviteUserBaseForm:: |
protected | property |
The route match. Overrides FormBase:: |
|
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |