original_string: private static function create_endpoints_for_facebook($issuer) {
          // The Facebook API version.
          $apiversion = '2.12';
          // The Graph API URL.
          $graphurl = 'https://graph.facebook.com/v' . $apiversion;
          // User information fields that we want to fetch.
          $infofields = [
              'id',
              'first_name',
              'last_name',
              'link',
              'picture.type(large)',
              'name',
              'email',
          ];
          $endpoints = [
              'authorization_endpoint' => sprintf('https://www.facebook.com/v%s/dialog/oauth', $apiversion),
              'token_endpoint' => $graphurl . '/oauth/access_token',
              'userinfo_endpoint' => $graphurl . '/me?fields=' . implode(',', $infofields)
          ];
  
          foreach ($endpoints as $name => $url) {
              $record = (object) [
                  'issuerid' => $issuer->get('id'),
                  'name' => $name,
                  'url' => $url
              ];
              $endpoint = new endpoint(0, $record);
              $endpoint->create();
          }
  
          // Create the field mappings.
          $mapping = [
              'name' => 'alternatename',
              'last_name' => 'lastname',
              'email' => 'email',
              'first_name' => 'firstname',
              'picture-data-url' => 'picture',
              'link' => 'url',
          ];
          foreach ($mapping as $external => $internal) {
              $record = (object) [
                  'issuerid' => $issuer->get('id'),
                  'externalfield' => $external,
                  'internalfield' => $internal
              ];
              $userfieldmapping = new user_field_mapping(0, $record);
              $userfieldmapping->create();
          }
          return $issuer;
      }
code: private static function create_endpoints_for_facebook($issuer) {
          // The Facebook API version.
          $apiversion = '2.12';
          // The Graph API URL.
          $graphurl = 'https://graph.facebook.com/v' . $apiversion;
          // User information fields that we want to fetch.
          $infofields = [
              'id',
              'first_name',
              'last_name',
              'link',
              'picture.type(large)',
              'name',
              'email',
          ];
          $endpoints = [
              'authorization_endpoint' => sprintf('https://www.facebook.com/v%s/dialog/oauth', $apiversion),
              'token_endpoint' => $graphurl . '/oauth/access_token',
              'userinfo_endpoint' => $graphurl . '/me?fields=' . implode(',', $infofields)
          ];
  
          foreach ($endpoints as $name => $url) {
              $record = (object) [
                  'issuerid' => $issuer->get('id'),
                  'name' => $name,
                  'url' => $url
              ];
              $endpoint = new endpoint(0, $record);
              $endpoint->create();
          }
  
          // Create the field mappings.
          $mapping = [
              'name' => 'alternatename',
              'last_name' => 'lastname',
              'email' => 'email',
              'first_name' => 'firstname',
              'picture-data-url' => 'picture',
              'link' => 'url',
          ];
          foreach ($mapping as $external => $internal) {
              $record = (object) [
                  'issuerid' => $issuer->get('id'),
                  'externalfield' => $external,
                  'internalfield' => $internal
              ];
              $userfieldmapping = new user_field_mapping(0, $record);
              $userfieldmapping->create();
          }
          return $issuer;
      }
code_tokens: private static function create_endpoints_for_facebook ( $ issuer ) { // The Facebook API version. $ apiversion = '2.12' ; // The Graph API URL. $ graphurl = 'https://graph.facebook.com/v' . $ apiversion ; // User information fields that we want to fetch. $ infofields = [ 'id' , 'first_name' , 'last_name' , 'link' , 'picture.type(large)' , 'name' , 'email' , ] ; $ endpoints = [ 'authorization_endpoint' => sprintf ( 'https://www.facebook.com/v%s/dialog/oauth' , $ apiversion ) , 'token_endpoint' => $ graphurl . '/oauth/access_token' , 'userinfo_endpoint' => $ graphurl . '/me?fields=' . implode ( ',' , $ infofields ) ] ; foreach ( $ endpoints as $ name => $ url ) { $ record = ( object ) [ 'issuerid' => $ issuer -> get ( 'id' ) , 'name' => $ name , 'url' => $ url ] ; $ endpoint = new endpoint ( 0 , $ record ) ; $ endpoint -> create ( ) ; } // Create the field mappings. $ mapping = [ 'name' => 'alternatename' , 'last_name' => 'lastname' , 'email' => 'email' , 'first_name' => 'firstname' , 'picture-data-url' => 'picture' , 'link' => 'url' , ] ; foreach ( $ mapping as $ external => $ internal ) { $ record = ( object ) [ 'issuerid' => $ issuer -> get ( 'id' ) , 'externalfield' => $ external , 'internalfield' => $ internal ] ; $ userfieldmapping = new user_field_mapping ( 0 , $ record ) ; $ userfieldmapping -> create ( ) ; } return $ issuer ; }
docstring: Create endpoints for facebook issuers.
  @param issuer $issuer issuer the endpoints should be created for.
  @return mixed
  @throws \coding_exception
  @throws \core\invalid_persistent_exception
docstring_tokens: Create endpoints for facebook issuers .