Skip to content
Snippets Groups Projects
Commit 4f242a35 authored by Project Update Bot's avatar Project Update Bot Committed by Nikolay Lobachev
Browse files

Issue #3287741 by LOBsTerr, Eduardo Morales Alberti: Automated Drupal 10 compatibility fixes

parent 0aa28234
No related branches found
No related tags found
No related merge requests found
......@@ -213,7 +213,8 @@ function ginvite_mail($key, &$message, $params) {
$group_invite_config = $group_plugin_collection->getConfiguration()['group_invitation'];
$language_manager->setConfigOverrideLanguage($original_language);
$subject = '';
$body = '';
if ($key == 'cancel') {
$subject = $group_invite_config['cancel_user_invitation_subject'];
$body = $group_invite_config['cancel_user_invitation_body'];
......@@ -312,6 +313,7 @@ function ginvite_entity_type_alter(array &$entity_types) {
* Implements hook_token_info().
*/
function ginvite_token_info() {
$tokens = [];
$tokens['register_link'] = [
'name' => t('Register Link'),
'description' => t('Url to register page with prefilled email address.'),
......@@ -364,7 +366,7 @@ function ginvite_tokens($type, $tokens, array $data, array $options, BubbleableM
* Implements hook_form_FORM_ID_alter().
*/
function ginvite_form_user_register_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$invitee_mail = \Drupal::request()->query->get("invitee_mail");
$invitee_mail = \Drupal::request()->query->get('invitee_mail');
if (isset($invitee_mail)) {
$search = ['-', '_'];
$replace = ['+', '/'];
......@@ -410,7 +412,6 @@ function ginvite_cron() {
}
// Query for all the invites that are expired for this group type.
$config_id = $group_type->getContentPlugin('group_invitation')->getContentTypeConfigId();
$expired_invites = $group_content_storage->getQuery()
->accessCheck(FALSE)
......
......@@ -2,21 +2,19 @@
namespace Drupal\ginvite\Controller;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityFormBuilderInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
use Drupal\Core\Session\AccountInterface;
use Drupal\ginvite\Plugin\GroupContentEnabler\GroupInvitation;
use Drupal\group\Entity\GroupContent;
use Drupal\group\Entity\GroupContentInterface;
use Drupal\group\Entity\GroupInterface;
use Drupal\group\GroupMembershipLoader;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Access\AccessResultInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\group\GroupMembershipLoader;
use Drupal\group\Entity\GroupInterface;
/**
* Handles Accept/Decline operations and Access check for them.
......
......@@ -2,8 +2,8 @@
namespace Drupal\ginvite\Event;
use Drupal\ginvite\GroupInvitation;
use Drupal\Component\EventDispatcher\Event;
use Drupal\ginvite\GroupInvitation;
/**
* Base invitation event.
......
......@@ -4,15 +4,15 @@ namespace Drupal\ginvite\EventSubscriber;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
use Drupal\ginvite\Event\InvitationBaseEvent;
use Drupal\ginvite\Event\UserLoginWithInvitationEvent;
use Drupal\ginvite\GroupInvitationLoader;
use Drupal\ginvite\Event\UserRegisteredFromInvitationEvent;
use Drupal\ginvite\GroupInvitationLoader;
use Drupal\ginvite\Plugin\GroupContentEnabler\GroupInvitation;
use Drupal\group\Entity\GroupContent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
......@@ -78,11 +78,11 @@ class GinviteSubscriber implements EventSubscriberInterface {
* The config factory.
*/
public function __construct(
GroupInvitationLoader $invitation_loader,
AccountInterface $current_user,
MessengerInterface $messenger,
GroupInvitationLoader $invitation_loader,
AccountInterface $current_user,
MessengerInterface $messenger,
LoggerChannelFactoryInterface $logger_factory,
ConfigFactoryInterface $config_factory
ConfigFactoryInterface $config_factory
) {
$this->groupInvitationLoader = $invitation_loader;
$this->currentUser = $current_user;
......@@ -158,7 +158,7 @@ class GinviteSubscriber implements EventSubscriberInterface {
}
/**
* Auto Accept Group Invitations from the ginvite module
* Auto Accept Group Invitations from the ginvite module.
*
* @param \Drupal\ginvite\Event\UserRegisteredFromInvitationEvent $event
* The UserRegisteredFromInvitationEvent to process.
......
......@@ -55,7 +55,6 @@ class BulkGroupInvitation extends FormBase implements ContainerInjectionInterfac
*/
protected $messenger;
/**
* Group.
*
......@@ -63,6 +62,20 @@ class BulkGroupInvitation extends FormBase implements ContainerInjectionInterfac
*/
protected $group;
/**
* The group membership loader.
*
* @var \Drupal\group\GroupMembershipLoaderInterface
*/
protected $groupMembershipLoader;
/**
* Group invitations loader.
*
* @var \Drupal\ginvite\GroupInvitationLoader
*/
protected $groupInvitationLoader;
/**
* Constructs a new BulkGroupInvitation Form.
*
......@@ -169,7 +182,7 @@ class BulkGroupInvitation extends FormBase implements ContainerInjectionInterfac
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
foreach ($form_state->getValues() as $key => $value) {
foreach (array_keys($form_state->getValues()) as $key) {
switch ($key) {
case 'email_address':
......@@ -189,6 +202,7 @@ class BulkGroupInvitation extends FormBase implements ContainerInjectionInterfac
public function submitForm(array &$form, FormStateInterface $form_state) {
// Prepare params to store them in tempstore.
$params = [];
$params['gid'] = $this->group->id();
$params['plugin'] = $this->group->getGroupType()->getContentPlugin('group_invitation')->getContentTypeConfigId();
$params['emails'] = $this->getSubmittedEmails($form_state);
......@@ -234,8 +248,8 @@ class BulkGroupInvitation extends FormBase implements ContainerInjectionInterfac
}
if (!empty($invalid_emails)) {
$message_singular = "The @error_message is not a valid e-mail address.";
$message_plural = "The e-mails: @error_message are not valid e-mail addresses.";
$message_singular = 'The @error_message is not a valid e-mail address.';
$message_plural = 'The e-mails: @error_message are not valid e-mail addresses.';
$this->displayErrorMessage($invalid_emails, $message_singular, $message_plural, $form_state);
}
......@@ -259,8 +273,8 @@ class BulkGroupInvitation extends FormBase implements ContainerInjectionInterfac
}
if (!empty($invalid_emails)) {
$message_singular = "User with @error_message e-mail already a member of this group.";
$message_plural = "Users with: @error_message e-mails already members of this group.";
$message_singular = 'User with @error_message e-mail already a member of this group.';
$message_plural = 'Users with: @error_message e-mails already members of this group.';
$this->displayErrorMessage($invalid_emails, $message_singular, $message_plural, $form_state);
}
......@@ -282,8 +296,8 @@ class BulkGroupInvitation extends FormBase implements ContainerInjectionInterfac
}
if (!empty($invalid_emails)) {
$message_singular = "Invitation to @error_message already sent.";
$message_plural = "Invitations to: @error_message already sent.";
$message_singular = 'Invitation to @error_message already sent.';
$message_plural = 'Invitations to: @error_message already sent.';
$this->displayErrorMessage($invalid_emails, $message_singular, $message_plural, $form_state);
}
......
......@@ -114,12 +114,12 @@ class BulkGroupInvitationConfirm extends ConfirmFormBase implements ContainerInj
*/
public function getDescription() {
$email_list_markup = "";
$email_list_markup = '';
foreach ($this->tempstore['emails'] as $email) {
$email_list_markup .= "{$email} <br />";
}
$description = $this->t("Invitation recipients: <br /> @email_list",
$description = $this->t('Invitation recipients: <br /> @email_list',
[
'@email_list' => new FormattableMarkup($email_list_markup, []),
]
......
......@@ -69,18 +69,6 @@ class GroupInvitation implements CacheableDependencyInterface {
return $this->groupContent->getEntity();
}
/**
* Returns the group roles for the invitation.
*
* @return \Drupal\group\Entity\GroupRoleInterface[]
* An array of group roles, keyed by their ID.
*/
public function getRoles() {
/** @var \Drupal\group\Entity\Storage\GroupRoleStorageInterface $group_role_storage */
$group_role_storage = \Drupal::entityTypeManager()->getStorage('group_role');
return $group_role_storage->loadByUserAndGroup($this->getUser(), $this->getGroup());
}
/**
* {@inheritdoc}
*/
......
......@@ -4,9 +4,9 @@ namespace Drupal\ginvite;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\group\Entity\GroupInterface;
use Drupal\ginvite\Plugin\GroupContentEnabler\GroupInvitation;
use Drupal\ginvite\GroupInvitation as GroupInvitationWrapper;
use Drupal\ginvite\Plugin\GroupContentEnabler\GroupInvitation;
use Drupal\group\Entity\GroupInterface;
/**
* Loader for wrapped GroupContent entities using the 'group_invitation' plugin.
......
......@@ -3,8 +3,8 @@
namespace Drupal\ginvite;
use Drupal\Core\Session\AccountInterface;
use Drupal\group\Entity\GroupInterface;
use Drupal\ginvite\Plugin\GroupContentEnabler\GroupInvitation;
use Drupal\group\Entity\GroupInterface;
/**
* Defines the group invitation loader interface.
......
......@@ -2,16 +2,16 @@
namespace Drupal\ginvite\Plugin\GroupContentEnabler;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\group\Access\GroupAccessResult;
use Drupal\group\Entity\GroupContentInterface;
use Drupal\group\Entity\GroupInterface;
use Drupal\group\Plugin\GroupContentEnablerBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\group\Entity\GroupContentInterface;
use Drupal\group\Access\GroupAccessResult;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......
......@@ -18,7 +18,7 @@ class GroupInviteExpireTest extends GroupBrowserTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'group',
'group_test_config',
'ginvite',
......
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\ginvite\Functional;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\group\Entity\GroupContent;
use Drupal\Tests\group\Functional\GroupBrowserTestBase;
/**
......@@ -18,7 +17,7 @@ class GroupInviteTest extends GroupBrowserTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'group',
'group_test_config',
'ginvite',
......@@ -108,7 +107,8 @@ class GroupInviteTest extends GroupBrowserTestBase {
$role->grantPermissions(['administer members']);
$role->save();
// Verify the normal member without the permission cannot add roles to users on invite.
// Verify the normal member without the permission cannot add roles
// to users on invite.
$this->drupalGet('/group/1/content/add/group_invitation');
$this->assertSession()->fieldExists('group_roles[default-custom]');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment