original_string: protected function fetch_members_from_consumer(ToolConsumer $consumer) {
          $dataconnector = $this->dataconnector;
  
          // Get membership URL template from consumer profile data.
          $defaultmembershipsurl = null;
          if (isset($consumer->profile->service_offered)) {
              $servicesoffered = $consumer->profile->service_offered;
              foreach ($servicesoffered as $service) {
                  if (isset($service->{'@id'}) && strpos($service->{'@id'}, 'tcp:ToolProxyBindingMemberships') !== false &&
                      isset($service->endpoint)) {
                      $defaultmembershipsurl = $service->endpoint;
                      if (isset($consumer->profile->product_instance->product_info->product_family->vendor->code)) {
                          $vendorcode = $consumer->profile->product_instance->product_info->product_family->vendor->code;
                          $defaultmembershipsurl = str_replace('{vendor_code}', $vendorcode, $defaultmembershipsurl);
                      }
                      $defaultmembershipsurl = str_replace('{product_code}', $consumer->getKey(), $defaultmembershipsurl);
                      break;
                  }
              }
          }
  
          $members = false;
  
          // Fetch the resource link linked to the consumer.
          $resourcelink = $dataconnector->get_resourcelink_from_consumer($consumer);
          if ($resourcelink !== null) {
              // Try to perform a membership service request using this resource link.
              $members = $this->do_resourcelink_membership_request($resourcelink);
          }
  
          // If membership service can't be performed through resource link, fallback through context memberships.
          if ($members === false) {
              // Fetch context records that are mapped to this ToolConsumer.
              $contexts = $dataconnector->get_contexts_from_consumer($consumer);
  
              // Perform membership service request for each of these contexts.
              foreach ($contexts as $context) {
                  $contextmembership = $this->do_context_membership_request($context, $resourcelink, $defaultmembershipsurl);
                  if ($contextmembership) {
                      // Add $contextmembership contents to $members array.
                      if (is_array($members)) {
                          $members = array_merge($members, $contextmembership);
                      } else {
                          $members = $contextmembership;
                      }
                  }
              }
          }
  
          return $members;
      }
code: protected function fetch_members_from_consumer(ToolConsumer $consumer) {
          $dataconnector = $this->dataconnector;
  
          // Get membership URL template from consumer profile data.
          $defaultmembershipsurl = null;
          if (isset($consumer->profile->service_offered)) {
              $servicesoffered = $consumer->profile->service_offered;
              foreach ($servicesoffered as $service) {
                  if (isset($service->{'@id'}) && strpos($service->{'@id'}, 'tcp:ToolProxyBindingMemberships') !== false &&
                      isset($service->endpoint)) {
                      $defaultmembershipsurl = $service->endpoint;
                      if (isset($consumer->profile->product_instance->product_info->product_family->vendor->code)) {
                          $vendorcode = $consumer->profile->product_instance->product_info->product_family->vendor->code;
                          $defaultmembershipsurl = str_replace('{vendor_code}', $vendorcode, $defaultmembershipsurl);
                      }
                      $defaultmembershipsurl = str_replace('{product_code}', $consumer->getKey(), $defaultmembershipsurl);
                      break;
                  }
              }
          }
  
          $members = false;
  
          // Fetch the resource link linked to the consumer.
          $resourcelink = $dataconnector->get_resourcelink_from_consumer($consumer);
          if ($resourcelink !== null) {
              // Try to perform a membership service request using this resource link.
              $members = $this->do_resourcelink_membership_request($resourcelink);
          }
  
          // If membership service can't be performed through resource link, fallback through context memberships.
          if ($members === false) {
              // Fetch context records that are mapped to this ToolConsumer.
              $contexts = $dataconnector->get_contexts_from_consumer($consumer);
  
              // Perform membership service request for each of these contexts.
              foreach ($contexts as $context) {
                  $contextmembership = $this->do_context_membership_request($context, $resourcelink, $defaultmembershipsurl);
                  if ($contextmembership) {
                      // Add $contextmembership contents to $members array.
                      if (is_array($members)) {
                          $members = array_merge($members, $contextmembership);
                      } else {
                          $members = $contextmembership;
                      }
                  }
              }
          }
  
          return $members;
      }
code_tokens: protected function fetch_members_from_consumer ( ToolConsumer $ consumer ) { $ dataconnector = $ this -> dataconnector ; // Get membership URL template from consumer profile data. $ defaultmembershipsurl = null ; if ( isset ( $ consumer -> profile -> service_offered ) ) { $ servicesoffered = $ consumer -> profile -> service_offered ; foreach ( $ servicesoffered as $ service ) { if ( isset ( $ service -> { '@id' } ) && strpos ( $ service -> { '@id' } , 'tcp:ToolProxyBindingMemberships' ) !== false && isset ( $ service -> endpoint ) ) { $ defaultmembershipsurl = $ service -> endpoint ; if ( isset ( $ consumer -> profile -> product_instance -> product_info -> product_family -> vendor -> code ) ) { $ vendorcode = $ consumer -> profile -> product_instance -> product_info -> product_family -> vendor -> code ; $ defaultmembershipsurl = str_replace ( '{vendor_code}' , $ vendorcode , $ defaultmembershipsurl ) ; } $ defaultmembershipsurl = str_replace ( '{product_code}' , $ consumer -> getKey ( ) , $ defaultmembershipsurl ) ; break ; } } } $ members = false ; // Fetch the resource link linked to the consumer. $ resourcelink = $ dataconnector -> get_resourcelink_from_consumer ( $ consumer ) ; if ( $ resourcelink !== null ) { // Try to perform a membership service request using this resource link. $ members = $ this -> do_resourcelink_membership_request ( $ resourcelink ) ; } // If membership service can't be performed through resource link, fallback through context memberships. if ( $ members === false ) { // Fetch context records that are mapped to this ToolConsumer. $ contexts = $ dataconnector -> get_contexts_from_consumer ( $ consumer ) ; // Perform membership service request for each of these contexts. foreach ( $ contexts as $ context ) { $ contextmembership = $ this -> do_context_membership_request ( $ context , $ resourcelink , $ defaultmembershipsurl ) ; if ( $ contextmembership ) { // Add $contextmembership contents to $members array. if ( is_array ( $ members ) ) { $ members = array_merge ( $ members , $ contextmembership ) ; } else { $ members = $ contextmembership ; } } } } return $ members ; }
docstring: Fetches the members that belong to a ToolConsumer.
  
  @param ToolConsumer $consumer
  @return bool|User[]
docstring_tokens: Fetches the members that belong to a ToolConsumer .