public static function loadMemberFromInvite($invite_code) {
    // Create Member entity.
    $memberValues = [
      'membership_id' => $invite_code,
      'is_non_y_member' => TRUE,
    ];

    // Load Member by unique Membership ID.
    $query = \Drupal::entityQuery('openy_campaign_member')
      ->condition('membership_id', $invite_code);
    $result = $query->execute();
    if (!empty($result)) {
      $memberID = reset($result);
      $member = Member::load($memberID);

      // Update Member entity with values.
      foreach ($memberValues as $field => $value) {
        $member->set($field, $value);
      }
      return $member;
    }

    /** @var Member $member Otherwise create temporary Member object. Will be saved later. */
    $member = \Drupal::entityTypeManager()
      ->getStorage('openy_campaign_member')
      ->create($memberValues);
    return $member;
  }
public static function loadMemberFromInvite($invite_code) {
    // Create Member entity.
    $memberValues = [
      'membership_id' => $invite_code,
      'is_non_y_member' => TRUE,
    ];

    // Load Member by unique Membership ID.
    $query = \Drupal::entityQuery('openy_campaign_member')
      ->condition('membership_id', $invite_code);
    $result = $query->execute();
    if (!empty($result)) {
      $memberID = reset($result);
      $member = Member::load($memberID);

      // Update Member entity with values.
      foreach ($memberValues as $field => $value) {
        $member->set($field, $value);
      }
      return $member;
    }

    /** @var Member $member Otherwise create temporary Member object. Will be saved later. */
    $member = \Drupal::entityTypeManager()
      ->getStorage('openy_campaign_member')
      ->create($memberValues);
    return $member;
  }
public static function loadMemberFromInvite ( $ invite_code ) { // Create Member entity. $ memberValues = [ 'membership_id' => $ invite_code , 'is_non_y_member' => TRUE , ] ; // Load Member by unique Membership ID. $ query = \ Drupal :: entityQuery ( 'openy_campaign_member' ) -> condition ( 'membership_id' , $ invite_code ) ; $ result = $ query -> execute ( ) ; if ( ! empty ( $ result ) ) { $ memberID = reset ( $ result ) ; $ member = Member :: load ( $ memberID ) ; // Update Member entity with values. foreach ( $ memberValues as $ field => $ value ) { $ member -> set ( $ field , $ value ) ; } return $ member ; } /** @var Member $member Otherwise create temporary Member object. Will be saved later. */ $ member = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'openy_campaign_member' ) -> create ( $ memberValues ) ; return $ member ; }
Load Member by invite code.

@param $invite_code
int Invite code.

@return bool|\Drupal\openy_campaign\Entity\Member
FALSE or Member object.

@throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
Load Member by invite code .