idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
15,700 | public function gitHubInitRepo ( InputInterface $ input , OutputInterface $ output ) { $ this -> output = $ output ; $ this -> runGitInit ( ) ; $ this -> runGitAdd ( ) ; $ this -> runGitCommit ( ) ; $ this -> runGitCreateRepo ( ) ; $ this -> runGitRemoteAddOrigin ( $ this -> getRepoURL ( $ input , $ output ) ) ; $ this... | Github init repo command . |
15,701 | public function getRepoURL ( InputInterface $ input , OutputInterface $ output ) { return 'git@github.com:' . $ this -> gitHubUsername ( $ input , $ output ) . '/' . $ this -> repoName ( $ input ) . '.git' ; } | Get github repo URL . |
15,702 | protected function gitHubUsername ( InputInterface $ input , OutputInterface $ output ) { $ username = $ input -> getArgument ( 'github_username' ) ; return isset ( $ username ) ? $ username : $ this -> getGithubUserNameFromConfig ( $ output ) ; } | Get github username . |
15,703 | protected function getGithubUserNameFromConfig ( OutputInterface $ output ) { $ username = $ this -> parser -> getGitHubUsername ( ) ; if ( is_null ( $ username ) ) { $ this -> showErrorRunLlumInitFirst ( $ output , 'username' ) ; } return $ username ; } | Get github username from llum config . |
15,704 | public function init ( InputInterface $ input , OutputInterface $ output ) { try { $ this -> executeWizard ( $ input , $ output ) ; $ this -> filesystem -> overwrite ( ( new LlumRCFile ( ) ) -> path ( ) , $ this -> compiler -> compile ( $ this -> filesystem -> get ( $ this -> getStubPath ( ) ) , $ this -> data ) ) ; } ... | init command . |
15,705 | protected function executeWizard ( InputInterface $ input , OutputInterface $ output ) { $ this -> askGithubUsername ( $ input , $ output ) ; $ this -> askGithubToken ( $ input , $ output ) ; $ this -> data = [ "GITHUB_USERNAME" => $ this -> github_username , "GITHUB_TOKEN" => $ this -> github_token , "GITHUB_TOKEN_NAM... | Executes wizard . |
15,706 | protected function boot ( InputInterface $ input , OutputInterface $ output ) { if ( $ this -> devtools ( ) == - 1 ) { return ; } $ this -> touchSqliteFile ( ) ; $ this -> sqliteEnv ( ) ; $ this -> migrate ( ) ; $ this -> serve ( $ input , $ output ) ; } | Executes boot command . |
15,707 | public function getPersonalToken ( $ username , $ password ) { $ response = $ this -> client -> request ( 'POST' , $ this -> authorization_url ( ) , [ "auth" => [ $ username , $ password ] , "json" => $ this -> authorizationsRequestJson ( ) ] ) ; $ response = json_decode ( $ response -> getBody ( ) ) ; $ this -> tokenN... | Obtain personal token . |
15,708 | public function createRepo ( $ repo_name , $ repo_description ) { return $ this -> client -> request ( 'POST' , $ this -> create_repo_url ( ) , [ "auth" => $ this -> credentials ( ) , "json" => json_decode ( $ this -> compileStub ( $ repo_name , $ repo_description ) , true ) , ] ) ; } | Create repo in github . |
15,709 | protected function compileStub ( $ repo_name , $ repo_description ) { $ data = [ "REPO_NAME" => $ repo_name , "REPO_DESCRIPTION" => $ repo_description ] ; return $ this -> compile ( $ this -> filesystem -> get ( $ this -> repo_json_stub ( ) ) , $ data ) ; } | Compile stub . |
15,710 | protected function compile ( $ template , $ data ) { foreach ( $ data as $ key => $ value ) { $ template = preg_replace ( "/\\$$key\\$/i" , $ value , $ template ) ; } return $ template ; } | Compile the template using the given data . |
15,711 | protected function initialize ( InputInterface $ input , OutputInterface $ output ) { parent :: initialize ( $ input , $ output ) ; if ( ( $ input -> hasOption ( 'dev' ) ) ) { if ( ( $ input -> getOption ( 'dev' ) ) ) { $ this -> installDev = true ; } } } | Initialize command . |
15,712 | private function requireComposerPackage ( $ package ) { $ composer = $ this -> findComposer ( ) ; $ process = new Process ( $ composer . ' require ' . $ package . '' . $ this -> getDevOption ( ) , null , null , null , null ) ; $ this -> output -> writeln ( '<info>Running composer require ' . $ package . $ this -> getDe... | Require composer package . |
15,713 | private function getPackageFromConfig ( $ name ) { if ( str_contains ( $ name , '/' ) ) { return $ this -> config -> get ( $ this -> getPackageNameByComposerName ( $ name ) ) ; } return $ this -> config -> get ( $ name ) ; } | get package from config . |
15,714 | private function obtainPackage ( $ name ) { $ package = $ this -> getPackageFromConfig ( $ name ) ; if ( $ package == null ) { $ this -> showPackageNotFoundError ( $ name ) ; return - 1 ; } return $ package ; } | Obtain package . |
15,715 | private function getPackageNameByComposerName ( $ composerPackageName ) { foreach ( $ this -> config -> all ( ) as $ key => $ configItem ) { if ( $ configItem [ 'name' ] == $ composerPackageName ) { return $ key ; } } } | Get package name by composer package name . |
15,716 | private function addTextIntoMountPoint ( $ mountpoint , $ textToAdd ) { passthru ( 'sed -i \'s/.*' . $ mountpoint . '.*/ \ \ \ \ \ \ \ ' . $ this -> scapeSingleQuotes ( preg_quote ( $ textToAdd ) ) . ',\n \ \ \ \ \ \ \ ' . $ mountpoint . '/\' ' . str_replace ( " " , "\ " , $ this -> laravel_config_file ) , $ error ) ; ... | Insert text into file using mountpoint . Mountpoint is maintained at file . |
15,717 | private function addFileIntoMountPoint ( $ mountpoint , $ fileToInsert , $ outputFile = null ) { if ( $ outputFile != null ) { passthru ( 'sed -e \'/' . $ mountpoint . '/r' . $ fileToInsert . '\' ' . str_replace ( " " , "\ " , $ this -> laravel_services_file ) . ' > ' . $ outputFile , $ error ) ; } else { passthru ( 's... | Insert file into file using mountpoint . |
15,718 | private function setupLaravelConfigFile ( $ providers , $ aliases ) { if ( $ this -> installConfigFile ( ) == - 1 ) { return - 1 ; } $ this -> addProviders ( $ providers ) ; $ this -> addAliases ( $ aliases ) ; } | Setup Laravel config file adding providers and aliases . |
15,719 | protected function addProviders ( $ providers ) { foreach ( $ providers as $ provider ) { $ this -> output -> writeln ( '<info>Adding ' . $ provider . ' to Laravel config app.php file</info>' ) ; $ this -> addProvider ( $ provider ) ; } } | Add providers to Laravel config file . |
15,720 | protected function addAliases ( $ aliases ) { if ( $ aliases == null ) { return ; } foreach ( $ aliases as $ alias => $ aliasClass ) { $ this -> output -> writeln ( '<info>Adding ' . $ aliasClass . ' to Laravel config app.php file</info>' ) ; $ this -> addAlias ( "'$alias' => " . $ aliasClass ) ; } } | Add aliases to Laravel config file . |
15,721 | public function destroy ( $ id ) { $ language = Language :: find ( $ id ) ; $ destroyResult = parent :: destroy ( $ id ) ; if ( $ destroyResult ) { \ File :: deleteDirectory ( resource_path ( 'lang/' . $ language -> abbr ) ) ; } return $ destroyResult ; } | After delete remove also the language folder . |
15,722 | public function getFileContent ( ) { $ filepath = $ this -> getFilePath ( ) ; if ( is_file ( $ filepath ) ) { $ wordsArray = include $ filepath ; asort ( $ wordsArray ) ; return $ wordsArray ; } return false ; } | get the content of a language file as an array sorted ascending . |
15,723 | public function setFileContent ( $ postArray ) { $ postArray = $ this -> prepareContent ( $ postArray ) ; $ return = ( int ) file_put_contents ( $ this -> getFilePath ( ) , print_r ( "<?php \n\n return " . $ this -> var_export54 ( $ postArray ) . ';' , true ) ) ; return $ return ; } | rewrite the file with the modified texts . |
15,724 | public function displayInputs ( $ fileArray , $ parents = [ ] , $ parent = '' , $ level = 0 ) { $ level ++ ; if ( $ parent ) { $ parents [ ] = $ parent ; } foreach ( $ fileArray as $ key => $ item ) { if ( is_array ( $ item ) ) { echo view ( ) -> make ( 'langfilemanager::language_headers' , [ 'header' => $ key , 'paren... | display the form that permits the editing . |
15,725 | private function setArrayValue ( & $ data , $ keys , $ value ) { foreach ( $ keys as $ key ) { $ data = & $ data [ $ key ] ; } return $ data = $ value ; } | set a value in a multidimensional array when knowing the keys . |
15,726 | public function createStreamedResponse ( Spreadsheet $ spreadsheet , $ type , $ status = 200 , $ headers = array ( ) , $ writerOptions = array ( ) ) { $ writer = IOFactory :: createWriter ( $ spreadsheet , $ type ) ; if ( ! empty ( $ writerOptions ) ) { $ this -> applyOptionsToWriter ( $ writer , $ writerOptions ) ; } ... | Return a StreamedResponse containing the file |
15,727 | public function defaultAction ( $ selfedit = 'false' ) { $ this -> selfedit = $ selfedit ; if ( $ selfedit == 'true' ) { $ this -> moufManager = MoufManager :: getMoufManager ( ) ; } else { $ this -> moufManager = MoufManager :: getMoufManagerHiddenInstance ( ) ; } $ this -> content -> addFile ( __DIR__ . '/../../../..... | Displays the first install screen . |
15,728 | public function configure ( $ selfedit = 'false' ) { $ this -> selfedit = $ selfedit ; if ( $ selfedit == 'true' ) { $ this -> moufManager = MoufManager :: getMoufManager ( ) ; } else { $ this -> moufManager = MoufManager :: getMoufManagerHiddenInstance ( ) ; } $ classNameMapper = ClassNameMapper :: createFromComposerF... | Displays the second install screen . |
15,729 | public function writeHtAccess ( $ selfedit = 'false' ) { if ( $ selfedit == 'true' ) { $ moufManager = MoufManager :: getMoufManager ( ) ; } else { $ moufManager = MoufManager :: getMoufManagerHiddenInstance ( ) ; } $ this -> exludeExtentions = $ moufManager -> getVariable ( 'splashexludeextentions' ) ; $ this -> exlud... | Write . htaccess . |
15,730 | public static function createDefault ( bool $ debugMode = true ) { $ block = new HtmlBlock ( ) ; $ template = new DefaultSplashTemplate ( $ block ) ; return new self ( $ template , $ block , $ debugMode ) ; } | Creates a default controller . |
15,731 | public function badRequest ( BadRequestException $ exception , ServerRequestInterface $ request ) : ResponseInterface { $ this -> exception = $ exception ; $ acceptType = $ request -> getHeader ( 'Accept' ) ; if ( is_array ( $ acceptType ) && count ( $ acceptType ) > 0 && strpos ( $ acceptType [ 0 ] , 'json' ) !== fals... | This function is called when a HTTP 400 error is triggered by the user . |
15,732 | public function pageNotFound ( ServerRequestInterface $ request ) : ResponseInterface { $ acceptType = $ request -> getHeader ( 'Accept' ) ; if ( is_array ( $ acceptType ) && count ( $ acceptType ) > 0 && strpos ( $ acceptType [ 0 ] , 'json' ) !== false ) { return new JsonResponse ( [ 'error' => [ 'message' => 'Page no... | This function is called when a HTTP 404 error is triggered by the user . |
15,733 | public function setClientModified ( DateTimeInterface $ set ) { $ this [ Option :: CLIENT_MODIFIED ] = $ set -> format ( Options :: DATETIME_FORMAT ) ; return $ this ; } | The value to store as the client_modified timestamp . Dropbox automatically records the time at which the file was written to the Dropbox servers . It can also record an additional timestamp provided by Dropbox desktop clients mobile clients and API apps of when the file was actually created or modified . |
15,734 | public static function availableSizes ( ) { $ r = [ ] ; foreach ( ( new ReflectionClass ( ThumbnailSize :: class ) ) -> getMethods ( ) as $ m ) { if ( preg_match ( '~^w[0-9]+h[0-9]+$~' , $ m -> getName ( ) ) ) { $ r [ ] = $ m -> getName ( ) ; } } ; return $ r ; } | Return a list ov available thumbnail sizes |
15,735 | protected function setArg ( $ key , $ value ) { if ( $ value !== null ) { $ this -> args [ $ key ] = $ value ; } return $ this ; } | Sets an argument value |
15,736 | public static function merge ( ... $ options ) { $ o = [ ] ; foreach ( $ options as $ opt ) { if ( $ opt instanceof Options ) { $ o = array_merge ( $ o , $ opt -> toArray ( ) ) ; } elseif ( is_array ( $ opt ) ) { $ o = array_merge ( $ o , $ opt ) ; } } return new self ( Util :: trimNulls ( $ o ) ) ; } | Create an Options object from a combination of configuration arrays and other option objects |
15,737 | public static function trimNulls ( array $ in ) { foreach ( $ in as $ k => $ v ) { if ( $ v === null ) { unset ( $ in [ $ k ] ) ; } } return $ in ; } | Trims nulls from the input |
15,738 | public function settings ( array $ settings ) { $ this -> settings = array_merge ( $ this -> settings , $ settings ) ; if ( $ this -> serviceClient ) $ this -> buildClient ( ) ; return $ this ; } | Merge additional settings with existing and save . Overrides existing settings as well . |
15,739 | private function buildClient ( ) { $ client = $ this -> getBaseClient ( ) ; if ( ! $ this -> description ) { $ this -> reloadDescription ( ) ; } $ this -> serviceClient = new GuzzleClient ( $ client , $ this -> description , array ( 'emitter' => $ this -> baseClient -> getEmitter ( ) , 'defaults' => $ this -> settings ... | Build new service client from descriptions . |
15,740 | private function loadBaseClient ( array $ settings = [ ] ) { if ( $ this -> baseClientAdapter ) $ settings [ 'adapter' ] = $ this -> baseClientAdapter ; return $ this -> baseClient = new BaseClient ( $ settings ) ; } | Set adapter and create Guzzle base client . |
15,741 | private function loadConfig ( ) { $ description = $ this -> loadResource ( 'service-config' ) ; $ description = $ description + [ 'baseUrl' => 'https://' . $ this -> settings [ 'shopUrl' ] , 'operations' => [ ] , 'models' => [ ] ] ; foreach ( $ description [ 'services' ] as $ serviceName ) { $ service = $ this -> loadR... | Load configuration file and parse resources . |
15,742 | private function loadServiceDescription ( array $ service , array $ description ) { foreach ( $ service as $ section => $ set ) { if ( $ section == 'operations' ) { foreach ( $ set as & $ op ) $ op [ 'parameters' ] = isset ( $ op [ 'parameters' ] ) ? $ op [ 'parameters' ] + $ this -> globalParams : $ this -> globalPara... | Load service description from resource add global parameters to operations . Operations and models added to full description . |
15,743 | public function getItem ( $ itemType , $ id , array $ queryString = [ ] ) { $ options = [ ] ; if ( $ queryString ) { $ options [ 'query' ] = $ queryString ; } $ response = $ this -> client -> request ( 'get' , $ itemType . '/' . $ id , $ options ) ; return [ 'statusCode' => $ response -> getStatusCode ( ) , 'body' => $... | Return the instance fields of itemtype identified by id . |
15,744 | public function initSessionByCredentials ( $ user , $ password ) { $ response = $ this -> request ( 'get' , 'initSession' , [ 'auth' => [ $ user , $ password ] ] ) ; if ( $ response -> getStatusCode ( ) != 200 || ! $ this -> sessionToken = json_decode ( $ response -> getBody ( ) -> getContents ( ) , true ) [ 'session_t... | Initialize a session with user credentials |
15,745 | public function initSessionByUserToken ( $ userToken ) { $ response = $ this -> request ( 'get' , 'initSession' , [ 'headers' => [ 'Authorization' => "user_token $userToken" ] ] ) ; if ( $ response -> getStatusCode ( ) != 200 || ! $ this -> sessionToken = json_decode ( $ response -> getBody ( ) -> getContents ( ) , tru... | initialize a session with a user token |
15,746 | public function killSession ( ) { $ response = $ this -> request ( 'get' , 'killSession' ) ; if ( $ response -> getStatusCode ( ) != 200 ) { $ body = json_decode ( $ response -> getBody ( ) -> getContents ( ) ) ; throw new Exception ( ErrorHandler :: getMessage ( $ body [ 0 ] ) ) ; } return true ; } | Kill client session . |
15,747 | public function request ( $ method , $ uri , array $ options = [ ] ) { $ apiToken = $ this -> addTokens ( ) ; try { $ options [ 'headers' ] [ 'Content-Type' ] = "application/json" ; $ sessionHeaders = [ ] ; if ( $ apiToken ) { if ( key_exists ( 'Session-Token' , $ apiToken ) && $ apiToken [ 'Session-Token' ] ) { $ sess... | Prepare and send a request to the GLPI Api . |
15,748 | private function addTokens ( ) { $ headers = [ ] ; if ( $ this -> appToken !== null ) { $ headers [ 'App-Token' ] = $ this -> appToken ; } if ( $ this -> sessionToken !== null ) { $ headers [ 'Session-Token' ] = $ this -> sessionToken ; } return $ headers ; } | generate headers containing session and app tokens for Http client object |
15,749 | public function makeChangelog ( $ repository ) { $ repoPrefix = 'remotes/upstream/' ; $ parentRevision = 'master' ; $ currentRevision = 'develop' ; $ changelog = $ this -> taskChangelog ( ) ; $ command = 'git describe --abbrev=0 --tags' ; $ lastTag = $ this -> _exec ( $ command ) -> getMessage ( ) ; if ( $ lastTag ) { ... | Task to create the changelog of the project |
15,750 | public function publishRelease ( $ repository , $ label = 'none' , $ origin = '' ) { if ( ! in_array ( $ label , [ 'rc' , 'beta' , 'alpha' , 'none' ] ) ) { throw new \ InvalidArgumentException ( 'Release label, can be rc, beta, alpha or none' ) ; } $ this -> options [ 'label' ] = $ label ; $ result = $ this -> makeChan... | Task to publish a release similar to git - flow |
15,751 | private function generateNextVersion ( $ currentVersion ) { $ type = $ this -> releaseType ; $ label = isset ( $ this -> options [ 'label' ] ) ? $ this -> options [ 'label' ] : 'none' ; $ validTypes = [ 'patch' , 'minor' , 'major' ] ; if ( ! in_array ( $ type , $ validTypes ) ) { throw new \ InvalidArgumentException ( ... | Generate the next semantic version |
15,752 | public function getMyProfiles ( ) { $ response = $ this -> client -> request ( 'get' , 'getMyProfiles' ) ; return [ 'statusCode' => $ response -> getStatusCode ( ) , 'body' => $ response -> getBody ( ) -> getContents ( ) , ] ; } | Return all the profiles associated to logged user . |
15,753 | public function getActiveProfile ( ) { $ response = $ this -> client -> request ( 'get' , 'getActiveProfile' ) ; return [ 'statusCode' => $ response -> getStatusCode ( ) , 'body' => $ response -> getBody ( ) -> getContents ( ) , ] ; } | Return the current active profile . |
15,754 | public function getActiveEntities ( ) { $ response = $ this -> client -> request ( 'get' , 'getActiveEntities' ) ; return [ 'statusCode' => $ response -> getStatusCode ( ) , 'body' => $ response -> getBody ( ) -> getContents ( ) , ] ; } | Return active entities of current logged user . |
15,755 | protected function isOriginAllowed ( ? string $ origin ) { if ( $ this -> isAllOriginsAllowed ( ) ) { return true ; } return str_is ( $ this -> allowOrigins , $ origin ) ; } | Returns whether or not the origin is allowed . |
15,756 | protected function isMethodAllowed ( ? string $ method ) { if ( $ this -> isAllMethodsAllowed ( ) ) { return true ; } return in_array ( strtoupper ( $ method ) , $ this -> allowMethods ) ; } | Returns whether or not the method is allowed . |
15,757 | protected function isHeaderAllowed ( ? string $ header ) { if ( $ this -> isAllHeadersAllowed ( ) ) { return true ; } return in_array ( strtolower ( $ header ) , $ this -> allowHeaders ) ; } | Returns whether or not the header is allowed . |
15,758 | public static function initialize ( $ url , $ token = null , $ options = [ ] , $ normalizers = [ ] ) { if ( ! isset ( static :: $ clientResolver ) ) { static :: setClientResolver ( function ( $ options ) { $ clientOptions = isset ( $ options [ 'client' ] ) ? $ options [ 'client' ] : [ ] ; return new Client ( $ clientOp... | Default method to initialize a Firebase client will set the ClientInterface dependency for you if not already set |
15,759 | public function get ( $ path = '' , Criteria $ criteria = null ) { $ request = $ this -> createRequest ( 'GET' , $ path , $ criteria ) ; return $ this -> handleRequest ( $ request ) ; } | Read data from path |
15,760 | public function set ( $ path , $ value = self :: NULL_ARGUMENT ) { $ request = $ this -> createRequest ( 'PUT' , $ path , $ value ) ; return $ this -> handleRequest ( $ request ) ; } | Set data in path |
15,761 | protected function createRequest ( $ method , $ path , $ value = null ) { list ( $ path , $ value ) = $ this -> evaluatePathValueArguments ( array ( $ path , $ value ) ) ; return $ this -> client -> createRequest ( $ method , $ this -> buildUrl ( $ path ) , $ this -> buildOptions ( $ value ) ) ; } | Create a Request object |
15,762 | protected function handleRequest ( RequestInterface $ request ) { if ( ! $ this -> getOption ( 'batch' , false ) ) { $ response = $ this -> client -> send ( $ request ) ; return $ this -> normalizeResponse ( $ response ) ; } $ this -> requests [ ] = $ request ; } | Stores requests when batching sends request |
15,763 | public function normalize ( $ normalizer ) { if ( is_string ( $ normalizer ) && isset ( $ this -> normalizers [ $ normalizer ] ) ) { $ this -> normalizer = $ this -> normalizers [ $ normalizer ] ; } else if ( $ normalizer instanceof NormalizerInterface ) { $ this -> normalizer = $ normalizer ; } return $ this ; } | Set a normalizer by string or a normalizer instance |
15,764 | protected function normalizeResponse ( ResponseInterface $ response ) { if ( ! is_null ( $ this -> normalizer ) ) { return $ this -> normalizer -> normalize ( $ response ) ; } return $ response -> json ( ) ; } | Normalizes the HTTP Request Client response |
15,765 | public function setNormalizers ( $ normalizers ) { foreach ( $ normalizers as $ normalizer ) { $ this -> normalizers [ $ normalizer -> getName ( ) ] = $ normalizer ; } return $ this ; } | Set normalizers in an associative array |
15,766 | protected function buildUrl ( $ path ) { $ baseUrl = $ this -> getOption ( 'base_url' ) ; $ url = $ baseUrl . ( ( substr ( $ baseUrl , - 1 ) == '/' || substr ( $ path , 0 , 1 ) == '/' ) ? '' : '/' ) . $ path ; if ( strpos ( $ url , '.json' ) === false ) { $ url .= '.json' ; } return $ url ; } | Prefix url with a base_url if present |
15,767 | protected function buildQuery ( $ data = null ) { $ params = array ( ) ; if ( $ data instanceof Criteria ) { $ params = array_merge ( $ params , $ data -> getParams ( ) ) ; $ params [ 'orderBy' ] = $ data -> getOrderBy ( ) ; } if ( $ token = $ this -> getOption ( 'token' , false ) ) { $ params [ 'auth' ] = $ token ; } ... | Build Query parameters for HTTP Request Client |
15,768 | protected function buildOptions ( $ data = null ) { $ options = array ( 'query' => $ this -> buildQuery ( $ data ) , 'debug' => $ this -> getOption ( 'debug' , false ) , 'timeout' => $ this -> getOption ( 'timeout' , 0 ) ) ; if ( ! is_null ( $ data ) && ! ( $ data instanceof Criteria ) ) { $ options [ 'json' ] = $ data... | Build options array for HTTP Request Client |
15,769 | protected function resolveClient ( ) { if ( ! isset ( $ this -> client ) ) { $ this -> setClient ( call_user_func ( static :: $ clientResolver , $ this -> getOptions ( ) ) ) ; } } | Inject client dependency |
15,770 | public function generateToken ( $ data , $ options = array ( ) ) { return $ this -> encodeToken ( $ this -> buildClaims ( $ options + array ( 'data' => $ data ) ) , $ this -> secret ) ; } | Generate a JWT token by specifying data and options |
15,771 | protected function encodeToken ( $ claims , $ secret , $ hashMethod = 'HS256' ) { if ( method_exists ( $ encoder = $ this -> resolveEncoder ( ) , 'encode' ) ) { return call_user_func_array ( array ( $ encoder , 'encode' ) , array ( $ claims , $ secret , $ hashMethod ) ) ; } throw new MissingEncoderException ( 'No JSON ... | Encodes token using a JWT encoder |
15,772 | protected function buildClaims ( $ options ) { $ claims = array ( ) ; foreach ( $ this -> requiredClaims as $ claimKey ) { list ( $ key , $ claim ) = $ this -> buildClaim ( $ claimKey ) ; $ claims [ $ key ] = $ claim ; } foreach ( array_intersect ( $ this -> availableClaims , array_keys ( $ options ) ) as $ claimKey ) ... | Build optional and required claims array |
15,773 | protected function buildClaim ( $ key , $ arg = null ) { $ claimBuilder = sprintf ( 'build%sClaim' , ucfirst ( $ key ) ) ; return $ this -> { $ claimBuilder } ( $ arg ) ; } | Constructs builder method and executes with arguments |
15,774 | protected function getValidTimestamp ( $ value ) { if ( gettype ( $ value ) == 'integer' ) { return $ value ; } if ( $ value instanceof DateTime ) { return $ value -> getTimestamp ( ) ; } throw new UnexpectedValueException ( 'Instance of DateTime required for a valid timestamp' ) ; } | Make sure the tmiestamp is formatted in seconds after epoch |
15,775 | protected function buildDataClaim ( $ value ) { @ json_encode ( $ value ) ; if ( ( $ errorCode = json_last_error ( ) ) !== JSON_ERROR_NONE ) { throw new UnexpectedValueException ( $ this -> jsonErrorMessage ( $ errorCode ) ) ; } return array ( 'd' , $ value ) ; } | Tests if data supplied is JSONifiable |
15,776 | protected function jsonErrorMessage ( $ errorNumber ) { $ messages = array ( JSON_ERROR_NONE => 'No error has occured' , JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded' , JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON' , JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly enc... | Returns an error message |
15,777 | public static function addDoubleQuotes ( $ input ) { $ output = $ input ; if ( substr ( $ input , 0 , 1 ) !== '"' ) { $ output = '"' . $ output ; } if ( substr ( strrev ( $ input ) , 0 , 1 ) !== '"' ) { $ output = $ output . '"' ; } return $ output ; } | Adds double quotes where necessary |
15,778 | public function verifyRequest ( $ data = NULL , $ bypassTimeCheck = FALSE ) { $ da = array ( ) ; if ( is_string ( $ data ) ) { $ each = explode ( '&' , $ data ) ; foreach ( $ each as $ e ) { list ( $ key , $ val ) = explode ( '=' , $ e ) ; $ da [ $ key ] = $ val ; } } elseif ( is_array ( $ data ) ) { $ da = $ data ; } ... | Verifies data returned by OAuth call |
15,779 | public function getAccessToken ( $ code = '' ) { $ dta = array ( 'client_id' => $ this -> _API [ 'API_KEY' ] , 'client_secret' => $ this -> _API [ 'API_SECRET' ] , 'code' => $ code ) ; $ data = $ this -> call ( [ 'METHOD' => 'POST' , 'URL' => 'https://' . $ this -> _API [ 'SHOP_DOMAIN' ] . '/admin/oauth/access_token' ,... | Calls API and returns OAuth Access Token which will be needed for all future requests |
15,780 | public function installURL ( $ data = array ( ) ) { return 'https://' . $ this -> _API [ 'SHOP_DOMAIN' ] . '/admin/oauth/authorize?client_id=' . $ this -> _API [ 'API_KEY' ] . '&scope=' . implode ( ',' , $ data [ 'permissions' ] ) . ( ! empty ( $ data [ 'redirect' ] ) ? '&redirect_uri=' . urlencode ( $ data [ 'redirect... | Returns a string of the install URL for the app |
15,781 | public function setMethod ( $ method ) { $ method = strtolower ( $ method ) ; if ( ! array_key_exists ( $ method , static :: $ methods ) ) { throw new \ InvalidArgumentException ( "Method [$method] not a valid HTTP method." ) ; } if ( $ this -> data && ! static :: $ methods [ $ method ] ) { throw new \ LogicException (... | Set the HTTP method of the request . |
15,782 | public function setHeader ( $ key , $ value = null , $ preserveCase = false ) { if ( $ value === null ) { list ( $ key , $ value ) = explode ( ':' , $ value , 2 ) ; } if ( ! $ preserveCase ) { $ key = strtolower ( $ key ) ; } $ key = trim ( $ key ) ; $ this -> headers [ $ key ] = trim ( $ value ) ; return $ this ; } | Set a specific header to be sent with the request . |
15,783 | public function getHeader ( $ key ) { $ key = strtolower ( $ key ) ; return isset ( $ this -> headers [ $ key ] ) ? $ this -> headers [ $ key ] : null ; } | Get a specific header from the request . |
15,784 | private function updateCookieHeader ( ) { $ strings = array ( ) ; foreach ( $ this -> cookies as $ key => $ value ) { $ strings [ ] = "{$key}={$value}" ; } $ this -> setHeader ( 'cookie' , implode ( '; ' , $ strings ) ) ; } | Read the request cookies and set the cookie header . |
15,785 | public function setData ( $ data ) { if ( $ data && ! static :: $ methods [ $ this -> method ] ) { throw new \ InvalidArgumentException ( "HTTP method [$this->method] does not allow POST data." ) ; } $ this -> data = $ data ; return $ this ; } | Set the POST data to be sent with the request . |
15,786 | public function encodeData ( ) { switch ( $ this -> encoding ) { case static :: ENCODING_JSON : return json_encode ( $ this -> data ) ; case static :: ENCODING_QUERY : return ( ! is_null ( $ this -> data ) ? http_build_query ( $ this -> data ) : '' ) ; case static :: ENCODING_RAW : return $ this -> data ; default : $ m... | Encode the POST data as a string . |
15,787 | public function auth ( $ user , $ pass ) { $ this -> user = $ user ; $ this -> pass = $ pass ; return $ this ; } | Set the HTTP basic username and password . |
15,788 | public function buildUrl ( $ url , array $ query ) { if ( empty ( $ query ) ) { return $ url ; } $ parts = parse_url ( $ url ) ; $ queryString = '' ; if ( isset ( $ parts [ 'query' ] ) && $ parts [ 'query' ] ) { $ queryString .= $ parts [ 'query' ] . '&' . http_build_query ( $ query ) ; } else { $ queryString .= http_b... | Build an URL with an optional query string . |
15,789 | public function newRequest ( $ method , $ url , $ data = array ( ) , $ encoding = Request :: ENCODING_QUERY ) { $ class = $ this -> requestClass ; $ request = new $ class ( $ this ) ; if ( $ this -> defaultHeaders ) { $ request -> setHeaders ( $ this -> defaultHeaders ) ; } if ( $ this -> defaultOptions ) { $ request -... | Create a new response object and set its values . |
15,790 | public function newJsonRequest ( $ method , $ url , $ data = array ( ) ) { return $ this -> newRequest ( $ method , $ url , $ data , Request :: ENCODING_JSON ) ; } | Create a new JSON request and set its values . |
15,791 | public function prepareRequest ( Request $ request ) { $ this -> ch = curl_init ( ) ; curl_setopt ( $ this -> ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ this -> ch , CURLOPT_HEADER , true ) ; if ( $ auth = $ request -> getUserAndPass ( ) ) { curl_setopt ( $ this -> ch , CURLOPT_USERPWD , $ auth ) ; } curl_s... | Prepare the curl resource for sending a request . |
15,792 | protected function parseHeaders ( array $ headers ) { $ this -> headers = array ( ) ; $ firstHeader = array_shift ( $ headers ) ; if ( ! preg_match ( '/^HTTP\/\d(\.\d)? [0-9]{3}/' , $ firstHeader ) ) { throw new \ InvalidArgumentException ( 'Invalid response header' ) ; } list ( , $ status ) = explode ( ' ' , $ firstHe... | Parse an array of headers . |
15,793 | protected function getEnvironmentFile ( ) { return $ this -> compiler -> compile ( $ this -> filesystem -> get ( $ this -> getSocialiteEnvironmentStubFile ( ) ) , [ strtoupper ( $ this -> socialNetwork ) . '_OAUTH_APP_ID' => $ this -> oauthApp -> getId ( ) , strtoupper ( $ this -> socialNetwork ) . '_OAUTH_APP_SECRET' ... | Get environment file . |
15,794 | protected function showInfoAboutSocialNetwork ( ) { $ this -> command -> info ( 'Configuring social network ' . ucfirst ( $ this -> name ( ) ) . '...' ) ; $ this -> command -> info ( 'Please register a new OAuth app for ' . ucfirst ( $ this -> name ( ) ) . '. Go to URL <question>' . $ this -> infoURL ( ) . '</question>... | Show info about social network |
15,795 | protected function obtainOAuthClientData ( ) { $ oauth = resolve ( \ Acacha \ LaravelSocial \ Services \ OAuthApp :: class ) ; $ oauth -> setId ( trim ( $ this -> command -> ask ( 'OAuth client id?' ) ) ) ; $ oauth -> setSecret ( trim ( $ this -> command -> ask ( 'OAuth client secret?' ) ) ) ; $ oauth -> setRedirectUrl... | Obtain OAuth client data . |
15,796 | public function findOrCreateUser ( $ socialUser ) { if ( $ authUser = $ this -> find ( $ socialUser ) ) { if ( $ user = $ authUser -> user ) { return $ user ; } return $ this -> createUser ( $ socialUser ) ; } $ userClass = $ this -> userModel ( ) ; if ( $ user = $ userClass :: where ( 'email' , $ socialUser -> email )... | Return user if exists ; create and return if doesn t . |
15,797 | public function find ( $ socialUser ) { return SocialUser :: where ( 'social_id' , $ socialUser -> id ) -> where ( 'social_type' , $ this -> provider ) -> first ( ) ; } | Find social user . |
15,798 | public function createSocialUser ( $ socialUser , $ userId ) { return SocialUser :: create ( [ 'user_id' => $ userId , 'social_id' => $ socialUser -> id , 'social_type' => $ this -> provider , 'nickname' => $ socialUser -> nickname , 'name' => $ socialUser -> name , 'email' => $ socialUser -> email , 'avatar' => $ soci... | Create social user . |
15,799 | private function createUser ( $ socialUser ) { $ user = [ 'name' => $ this -> validName ( $ socialUser ) , 'email' => $ socialUser -> email , ] ; if ( $ this -> username ( ) === 'username' ) { $ user [ 'username' ] = $ socialUser -> nickname ; } $ userClass = $ this -> userModel ( ) ; return $ userClass :: create ( $ u... | Create regular user . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.