private function validateMemberBranch() {
    /** @var \Drupal\node\Entity\Node $campaign Campaign node object. */
    $campaign = $this->getCampaign();
    /** @var \Drupal\openy_campaign\Entity\Member $member Temporary Member object. Will be saved by submit. */
    $member = $this->getMember();

    $branchesField = $campaign->get('field_campaign_branch_target')->getValue();
    $campaignBranches = [];
    foreach ($branchesField as $branch) {
      $campaignBranches[] = $branch['target_id'];
    }

    $memberBranch = $member->getBranchId();

    if (in_array($memberBranch, $campaignBranches)) {
      return ['status' => TRUE, 'error' => ''];
    }

    return ['status' => FALSE, 'error' => t('Branch is not included.')->render()];
  }
private function validateMemberBranch() {
    /** @var \Drupal\node\Entity\Node $campaign Campaign node object. */
    $campaign = $this->getCampaign();
    /** @var \Drupal\openy_campaign\Entity\Member $member Temporary Member object. Will be saved by submit. */
    $member = $this->getMember();

    $branchesField = $campaign->get('field_campaign_branch_target')->getValue();
    $campaignBranches = [];
    foreach ($branchesField as $branch) {
      $campaignBranches[] = $branch['target_id'];
    }

    $memberBranch = $member->getBranchId();

    if (in_array($memberBranch, $campaignBranches)) {
      return ['status' => TRUE, 'error' => ''];
    }

    return ['status' => FALSE, 'error' => t('Branch is not included.')->render()];
  }
private function validateMemberBranch ( ) { /** @var \Drupal\node\Entity\Node $campaign Campaign node object. */ $ campaign = $ this -> getCampaign ( ) ; /** @var \Drupal\openy_campaign\Entity\Member $member Temporary Member object. Will be saved by submit. */ $ member = $ this -> getMember ( ) ; $ branchesField = $ campaign -> get ( 'field_campaign_branch_target' ) -> getValue ( ) ; $ campaignBranches = [ ] ; foreach ( $ branchesField as $ branch ) { $ campaignBranches [ ] = $ branch [ 'target_id' ] ; } $ memberBranch = $ member -> getBranchId ( ) ; if ( in_array ( $ memberBranch , $ campaignBranches ) ) { return [ 'status' => TRUE , 'error' => '' ] ; } return [ 'status' => FALSE , 'error' => t ( 'Branch is not included.' ) -> render ( ) ] ; }
Check if the member branch fit to the Campaign selected branches.

@return array Array with status and error message.
Check if the member branch fit to the Campaign selected branches .