public function getCampaignBranches($node) {

    $targets = [];
    $ids = [];
    $output = [
      'branches' => [],
      'targets' => [],
    ];

    $branchIds = $node->get('field_campaign_branch_target')->getValue();

    foreach ($branchIds as $branchId) {
      $ids[] = $branchId['target_id'];
      $targets[$branchId['target_id']] = $branchId['value'];
    }

    if (!empty($ids)) {
      $query = $this->connection->select('openy_campaign_mapping_branch', 'b');
      $query->fields('b', ['personify_branch', 'branch']);
      $query->join('node_field_data', 'n', 'n.nid = b.branch');
      $query->fields('n', ['title']);
      $query->condition('b.branch', $ids, 'IN');
      $query->orderBy('b.personify_branch');

      $result = $query->execute()->fetchAllAssoc('branch');

      $output['branches'] = $result;
      $output['targets'] = $targets;
    }

    return $output;
  }
public function getCampaignBranches($node) {

    $targets = [];
    $ids = [];
    $output = [
      'branches' => [],
      'targets' => [],
    ];

    $branchIds = $node->get('field_campaign_branch_target')->getValue();

    foreach ($branchIds as $branchId) {
      $ids[] = $branchId['target_id'];
      $targets[$branchId['target_id']] = $branchId['value'];
    }

    if (!empty($ids)) {
      $query = $this->connection->select('openy_campaign_mapping_branch', 'b');
      $query->fields('b', ['personify_branch', 'branch']);
      $query->join('node_field_data', 'n', 'n.nid = b.branch');
      $query->fields('n', ['title']);
      $query->condition('b.branch', $ids, 'IN');
      $query->orderBy('b.personify_branch');

      $result = $query->execute()->fetchAllAssoc('branch');

      $output['branches'] = $result;
      $output['targets'] = $targets;
    }

    return $output;
  }
public function getCampaignBranches ( $ node ) { $ targets = [ ] ; $ ids = [ ] ; $ output = [ 'branches' => [ ] , 'targets' => [ ] , ] ; $ branchIds = $ node -> get ( 'field_campaign_branch_target' ) -> getValue ( ) ; foreach ( $ branchIds as $ branchId ) { $ ids [ ] = $ branchId [ 'target_id' ] ; $ targets [ $ branchId [ 'target_id' ] ] = $ branchId [ 'value' ] ; } if ( ! empty ( $ ids ) ) { $ query = $ this -> connection -> select ( 'openy_campaign_mapping_branch' , 'b' ) ; $ query -> fields ( 'b' , [ 'personify_branch' , 'branch' ] ) ; $ query -> join ( 'node_field_data' , 'n' , 'n.nid = b.branch' ) ; $ query -> fields ( 'n' , [ 'title' ] ) ; $ query -> condition ( 'b.branch' , $ ids , 'IN' ) ; $ query -> orderBy ( 'b.personify_branch' ) ; $ result = $ query -> execute ( ) -> fetchAllAssoc ( 'branch' ) ; $ output [ 'branches' ] = $ result ; $ output [ 'targets' ] = $ targets ; } return $ output ; }
Get selected Branches from current campaign.

@param $node

@return mixed
Get selected Branches from current campaign .