class GroupRequestMembershipRejectForm in Open Social 8.9
Same name and namespace in other branches
- 10.3.x modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRejectForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRejectForm
- 10.0.x modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRejectForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRejectForm
- 10.1.x modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRejectForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRejectForm
- 10.2.x modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRejectForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRejectForm
Provides a confirmation form before rejecting membership.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\social_group_request\Form\GroupRequestMembershipRejectForm
Expanded class hierarchy of GroupRequestMembershipRejectForm
1 file declares its use of GroupRequestMembershipRejectForm
- SocialGroupRequestRouteSubscriber.php in modules/
social_features/ social_group/ modules/ social_group_request/ src/ Routing/ SocialGroupRequestRouteSubscriber.php
File
- modules/
social_features/ social_group/ modules/ social_group_request/ src/ Form/ GroupRequestMembershipRejectForm.php, line 20
Namespace
Drupal\social_group_request\FormView source
class GroupRequestMembershipRejectForm extends FormBase {
/**
* Group entity.
*
* @var \Drupal\group\Entity\GroupInterface
*/
protected $group;
/**
* Group membership request.
*
* @var \Drupal\group\Entity\GroupContentInterface
*/
protected $groupContent;
/**
* The redirect destination helper.
*
* @var \Drupal\Core\Routing\RedirectDestinationInterface
*/
protected $redirectDestination;
/**
* The cache tags invalidator.
*
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
*/
protected $cacheTagsInvalidator;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* GroupRequestMembershipRejectForm constructor.
*
* @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination
* The redirect destination.
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
* The cache tags invalidator.
* @param \Drupal\Core\Session\AccountInterface $current_user
* The current user.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation.
*/
public function __construct(RedirectDestinationInterface $redirect_destination, CacheTagsInvalidatorInterface $cache_tags_invalidator, AccountInterface $current_user, TranslationInterface $string_translation) {
$this->redirectDestination = $redirect_destination;
$this->cacheTagsInvalidator = $cache_tags_invalidator;
$this->currentUser = $current_user;
$this
->setStringTranslation($string_translation);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('redirect.destination'), $container
->get('cache_tags.invalidator'), $container
->get('current_user'), $container
->get('string_translation'));
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'grequest_group_request_membership_reject';
}
/**
* {@inheritdoc}
*/
private function getCancelUrl() {
return Url::fromUserInput($this->redirectDestination
->get());
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, GroupInterface $group = NULL, GroupContentInterface $group_content = NULL) {
$this->group = $group;
$this->groupContent = $group_content;
$form['#attributes']['class'][] = 'form--default';
$form['question'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this
->t('Are you sure you want to reject the membership request for @name?', [
'@name' => $group_content
->getEntity()
->getDisplayName(),
]),
'#weight' => 1,
'#prefix' => '<div class="card"><div class="card__block">',
'#suffix' => '</div></div>',
];
$form['actions']['#type'] = 'actions';
$form['actions']['cancel'] = [
'#type' => 'link',
'#title' => $this
->t('Cancel'),
'#attributes' => [
'class' => [
'button',
'button--flat',
'btn',
'btn-flat',
'waves-effect',
'waves-btn',
],
],
'#url' => $this
->getCancelUrl(),
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Yes'),
'#button_type' => 'primary',
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->groupContent
->set('grequest_status', GroupMembershipRequest::REQUEST_REJECTED)
->set('grequest_updated_by', $this->currentUser
->id());
$result = $this->groupContent
->save();
if ($result) {
$this
->messenger()
->addStatus($this
->t('Membership request rejected'));
}
else {
$this
->messenger()
->addError($this
->t('Error updating Request'));
}
$this->cacheTagsInvalidator
->invalidateTags([
'request-membership:' . $this->group
->id(),
]);
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}
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 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
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 |
GroupRequestMembershipRejectForm:: |
protected | property | The cache tags invalidator. | |
GroupRequestMembershipRejectForm:: |
protected | property | The current user. | |
GroupRequestMembershipRejectForm:: |
protected | property | Group entity. | |
GroupRequestMembershipRejectForm:: |
protected | property | Group membership request. | |
GroupRequestMembershipRejectForm:: |
protected | property |
The redirect destination helper. Overrides RedirectDestinationTrait:: |
|
GroupRequestMembershipRejectForm:: |
public | function |
Form constructor. Overrides FormInterface:: |
|
GroupRequestMembershipRejectForm:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
|
GroupRequestMembershipRejectForm:: |
private | function | ||
GroupRequestMembershipRejectForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
GroupRequestMembershipRejectForm:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
GroupRequestMembershipRejectForm:: |
public | function | GroupRequestMembershipRejectForm constructor. | |
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 | 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. |