class EventAnEnrollActionForm in Open Social 8.5
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_an_enroll/src/Form/EventAnEnrollActionForm.php \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
- 8.3 modules/social_features/social_event/modules/social_event_an_enroll/src/Form/EventAnEnrollActionForm.php \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
- 8.4 modules/social_features/social_event/modules/social_event_an_enroll/src/Form/EventAnEnrollActionForm.php \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
- 8.6 modules/social_features/social_event/modules/social_event_an_enroll/src/Form/EventAnEnrollActionForm.php \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
- 8.7 modules/social_features/social_event/modules/social_event_an_enroll/src/Form/EventAnEnrollActionForm.php \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
- 8.8 modules/social_features/social_event/modules/social_event_an_enroll/src/Form/EventAnEnrollActionForm.php \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
- 10.3.x modules/social_features/social_event/modules/social_event_an_enroll/src/Form/EventAnEnrollActionForm.php \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
- 10.0.x modules/social_features/social_event/modules/social_event_an_enroll/src/Form/EventAnEnrollActionForm.php \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
- 10.1.x modules/social_features/social_event/modules/social_event_an_enroll/src/Form/EventAnEnrollActionForm.php \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
- 10.2.x modules/social_features/social_event/modules/social_event_an_enroll/src/Form/EventAnEnrollActionForm.php \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
Class EventAnEnrollActionForm.
@package Drupal\social_event_an_enroll\Form
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\social_event\Form\EnrollActionForm implements ContainerInjectionInterface
- class \Drupal\social_event_an_enroll\Form\EventAnEnrollActionForm
- class \Drupal\social_event\Form\EnrollActionForm implements ContainerInjectionInterface
Expanded class hierarchy of EventAnEnrollActionForm
File
- modules/
social_features/ social_event/ modules/ social_event_an_enroll/ src/ Form/ EventAnEnrollActionForm.php, line 16
Namespace
Drupal\social_event_an_enroll\FormView source
class EventAnEnrollActionForm extends EnrollActionForm {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'event_an_enroll_action_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, Node $node = NULL) {
$nid = $node
->id();
$token = $this
->getRequest()->query
->get('token');
if (!empty($token) && \Drupal::service('social_event_an_enroll.service')
->tokenExists($token, $nid)) {
$form['event'] = [
'#type' => 'hidden',
'#value' => $nid,
];
$form['enroll_for_this_event'] = [
'#type' => 'submit',
'#value' => $this
->t('Enrolled'),
'#attributes' => [
'class' => [
'btn',
'btn-accent',
'btn-lg',
'btn-raised',
'brand-bg-accent',
'dropdown-toggle',
'waves-effect',
],
'autocomplete' => 'off',
'data-toggle' => 'dropdown',
'aria-haspopup' => 'true',
'aria-expanded' => 'false',
'data-caret' => 'true',
],
];
$cancel_text = $this
->t('Cancel enrollment');
$form['feedback_user_has_enrolled'] = [
'#markup' => '<ul class="dropdown-menu dropdown-menu-right"><li><a href="#" class="enroll-form-submit"> ' . $cancel_text . ' </a></li></ul>',
];
$form['#attached']['library'][] = 'social_event/form_submit';
}
else {
if ($this
->eventHasBeenFinished($node)) {
$form['event_enrollment'] = [
'#type' => 'submit',
'#value' => $this
->t('Event has passed'),
'#disabled' => TRUE,
'#attributes' => [
'class' => [
'btn',
'btn-accent',
'btn-lg',
'btn-raised',
'brand-bg-accent',
'waves-effect',
],
],
];
}
else {
$attributes = [
'class' => [
'use-ajax',
'js-form-submit',
'form-submit',
'btn',
'btn-accent',
'btn-lg',
],
'data-dialog-type' => 'modal',
'data-dialog-options' => json_encode([
'title' => t('Enroll in') . ' ' . strip_tags($node
->getTitle()),
'width' => 'auto',
]),
];
$form['event_enrollment'] = [
'#type' => 'link',
'#title' => $this
->t('Enroll'),
'#url' => Url::fromRoute('social_event_an_enroll.enroll_dialog', [
'node' => $nid,
]),
'#attributes' => $attributes,
];
}
}
$form['#cache'] = [
'max-age' => 0,
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$uid = $this->currentUser
->id();
$token = $this
->getRequest()->query
->get('token');
if (!empty($token)) {
$nid = $form_state
->getValue('event');
$conditions = [
'field_account' => $uid,
'field_event' => $nid,
'field_token' => $token,
];
$enrollments = $this->entityStorage
->loadByProperties($conditions);
// Invalidate cache for our enrollment cache tag in
// social_event_node_view_alter().
$cache_tag = 'enrollment:' . $nid . '-' . $uid;
Cache::invalidateTags([
$cache_tag,
]);
if ($enrollment = array_pop($enrollments)) {
$enrollment
->delete();
drupal_set_message($this
->t('You are no longer enrolled in this event. Your personal data used for the enrollment is also deleted.'));
}
}
}
}
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 | |
EnrollActionForm:: |
protected | property |
The config factory. Overrides FormBase:: |
|
EnrollActionForm:: |
protected | property | The current user. | |
EnrollActionForm:: |
protected | property | The node storage for event enrollments. | |
EnrollActionForm:: |
protected | property | The entity type manager. | |
EnrollActionForm:: |
protected | property | The module handler. | |
EnrollActionForm:: |
protected | property |
The routing matcher to get the nid. Overrides FormBase:: |
|
EnrollActionForm:: |
protected | property | The user storage. | |
EnrollActionForm:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
|
EnrollActionForm:: |
protected | function | Function to determine if an event has been finished. | |
EnrollActionForm:: |
public | function | Get group object where event enrollment is posted in. | |
EnrollActionForm:: |
public | function | Constructs an Enroll Action Form. | |
EventAnEnrollActionForm:: |
public | function |
Form constructor. Overrides EnrollActionForm:: |
|
EventAnEnrollActionForm:: |
public | function |
Returns a unique string identifying the form. Overrides EnrollActionForm:: |
|
EventAnEnrollActionForm:: |
public | function |
Form submission handler. Overrides EnrollActionForm:: |
|
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 |
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 | property | The logger channel factory 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. |