You are here

public function SocialBulkGroupInvitation::extractEmailsFrom in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php \Drupal\social_group_invite\Form\SocialBulkGroupInvitation::extractEmailsFrom()
  2. 10.0.x modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php \Drupal\social_group_invite\Form\SocialBulkGroupInvitation::extractEmailsFrom()
  3. 10.1.x modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php \Drupal\social_group_invite\Form\SocialBulkGroupInvitation::extractEmailsFrom()
  4. 10.2.x modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php \Drupal\social_group_invite\Form\SocialBulkGroupInvitation::extractEmailsFrom()

Custom function to extract email addresses from a string.

2 calls to SocialBulkGroupInvitation::extractEmailsFrom()
SocialBulkGroupInvitation::submitForm in modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php
Custom form submit.
SocialBulkGroupInvitation::validateForm in modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php
Custom form validation.

File

modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php, line 452

Class

SocialBulkGroupInvitation
Class SocialBulkGroupInvitation.

Namespace

Drupal\social_group_invite\Form

Code

public function extractEmailsFrom($string) {

  // Remove select2 ID parameter.
  $string = str_replace('$ID:', '', $string);
  preg_match_all("/[\\._a-zA-Z0-9+-]+@[\\._a-zA-Z0-9+-]+/i", $string, $matches);
  if (is_array($matches[0]) && count($matches[0]) === 1) {
    return reset($matches[0]);
  }
  return $matches[0];
}