idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
7,700 | protected function createMenu ( ) { try { $ this -> warnIfSpatieMenuIsNotInstalled ( ) ; } catch ( \ Exception $ e ) { $ this -> error ( $ e -> getMessage ( ) ) ; return ; } Artisan :: call ( 'make:menu' , [ 'link' => $ link = undot_path ( $ this -> argument ( 'link' ) ) , 'name' => ucfirst ( $ link ) , ] ) ; $ this ->... | Create menu . |
7,701 | protected function createView ( $ name = null ) { if ( $ name == null ) { $ name = $ this -> action ( ) ; } Artisan :: call ( 'make:view' , [ 'name' => $ name ] ) ; $ this -> info ( 'View ' . undot_path ( $ name ) . '.blade.php created.' ) ; } | Create View . |
7,702 | protected function createController ( ) { Artisan :: call ( 'make:controller' , [ 'name' => $ controller = $ this -> controllerWithoutMethod ( $ this -> action ( ) ) ] ) ; $ this -> addMethodToController ( $ controller , $ this -> controllerMethod ( $ this -> action ( ) ) ) ; $ this -> info ( 'Controller ' . $ controll... | Create regular controller . |
7,703 | protected function createResourceController ( ) { Artisan :: call ( 'make:controller' , [ 'name' => $ controller = $ this -> controllerWithoutMethod ( $ this -> action ( ) ) , '--resource' => true ] ) ; $ this -> info ( 'Resource Controller ' . $ controller . ' created.' ) ; $ this -> createView ( $ this -> argument ( ... | Create resource controller . |
7,704 | protected function addMethodToController ( $ controller , $ controllerMethod ) { $ tmpfile = $ this -> createTmpFileWithMethod ( $ controllerMethod ) ; $ path = $ this -> getPath ( $ tmpfile ) ; add_file_into_file ( '\/\/' , $ path , app_path ( 'Http/Controllers/' . $ controller . '.php' ) ) ; } | Add method to controller . |
7,705 | protected function createTmpFileWithMethod ( $ controllerMethod ) { $ temp = tmpfile ( ) ; fwrite ( $ temp , $ this -> getMethodCode ( $ controllerMethod ) ) ; return $ temp ; } | Crete tmp file with route to add . |
7,706 | public function code ( ) { return $ this -> compiler -> compile ( $ this -> filesystem -> get ( $ this -> getStubPath ( ) ) , $ this -> obtainReplacements ( ) ) ; } | Generate route code . |
7,707 | public function findOne ( $ criteria = null , $ projection = null ) { $ items = $ this -> find ( $ criteria , $ projection ) -> limit ( 1 ) -> toArray ( ) ; return isset ( $ items [ 0 ] ) ? $ items [ 0 ] : null ; } | Find one document |
7,708 | public function service ( $ name , $ callable ) { $ this -> registry [ $ name ] = function ( $ c ) use ( $ callable ) { static $ object ; if ( null === $ object ) { $ object = $ callable ( $ c ) ; } return $ object ; } ; return $ this ; } | Returns a closure that stores the result of the given closure |
7,709 | public function baseUrl ( $ path ) { $ url = '' ; if ( \ strpos ( $ path , ':' ) === false ) { $ url .= $ this -> registry [ 'base_url' ] . '/' . \ ltrim ( $ path , '/' ) ; } else { $ url = $ this -> pathToUrl ( $ path ) ; } return $ url ; } | Returns link based on the base url of the app |
7,710 | public function set ( $ key , $ value ) { $ keys = \ explode ( '/' , $ key ) ; if ( \ count ( $ keys ) > 5 ) return false ; switch ( \ count ( $ keys ) ) { case 1 : $ this -> registry [ $ keys [ 0 ] ] = $ value ; break ; case 2 : $ this -> registry [ $ keys [ 0 ] ] [ $ keys [ 1 ] ] = $ value ; break ; case 3 : $ this -... | Put a value in the Lime registry |
7,711 | public function path ( ) { $ args = \ func_get_args ( ) ; switch ( \ count ( $ args ) ) { case 1 : $ file = $ args [ 0 ] ; if ( $ this -> isAbsolutePath ( $ file ) && \ file_exists ( $ file ) ) { return $ file ; } $ parts = \ explode ( ':' , $ file , 2 ) ; if ( count ( $ parts ) == 2 ) { if ( ! isset ( $ this -> paths ... | Path helper method |
7,712 | public function cache ( ) { $ args = \ func_get_args ( ) ; switch ( \ count ( $ args ) ) { case 1 : return $ this -> helper ( 'cache' ) -> read ( $ args [ 0 ] ) ; case 2 : return $ this -> helper ( 'cache' ) -> write ( $ args [ 0 ] , $ args [ 1 ] ) ; } return null ; } | Cache helper method |
7,713 | public function block ( $ name , $ options = [ ] ) { if ( ! isset ( $ this -> blocks [ $ name ] ) ) return null ; $ options = \ array_merge ( [ 'print' => true ] , $ options ) ; $ block = \ implode ( "\n" , $ this -> blocks [ $ name ] ) ; if ( $ options [ 'print' ] ) { echo $ block ; } return $ block ; } | Get block content |
7,714 | public function param ( $ index = null , $ default = null , $ source = null ) { $ src = $ source ? $ source : $ _REQUEST ; $ cast = null ; if ( \ strpos ( $ index , ':' ) !== false ) { list ( $ index , $ cast ) = \ explode ( ':' , $ index , 2 ) ; } $ value = fetch_from_array ( $ src , $ index , $ default ) ; if ( $ cas... | Get request variables |
7,715 | public function get ( $ path , $ callback , $ condition = true ) { if ( ! $ this -> req_is ( 'get' ) ) return ; $ this -> bind ( $ path , $ callback , $ condition ) ; } | Bind GET request to route |
7,716 | public function post ( $ path , $ callback , $ condition = true ) { if ( ! $ this -> req_is ( 'post' ) ) return ; $ this -> bind ( $ path , $ callback , $ condition ) ; } | Bind POST request to route |
7,717 | public function bindClass ( $ class , $ alias = false ) { $ self = $ this ; $ clean = $ alias ? $ alias : \ trim ( \ strtolower ( \ str_replace ( "\\" , "/" , $ class ) ) , "\\" ) ; $ this -> bind ( '/' . $ clean . '/*' , function ( ) use ( $ self , $ class , $ clean ) { $ parts = \ explode ( '/' , \ trim ( \ preg_repl... | Bind Class to routes |
7,718 | public function bind ( $ path , $ callback , $ condition = true ) { if ( ! $ condition ) return ; if ( ! isset ( $ this -> routes [ $ path ] ) ) { $ this -> routes [ $ path ] = [ ] ; } if ( \ is_object ( $ callback ) && $ callback instanceof \ Closure ) { $ callback = $ callback -> bindTo ( $ this , $ this ) ; } if ( \... | Bind request to route |
7,719 | protected function render_route ( $ route , $ params = [ ] ) { $ output = false ; if ( isset ( $ this -> routes [ $ route ] ) ) { $ ret = null ; if ( \ is_callable ( $ this -> routes [ $ route ] ) ) { $ ret = \ call_user_func ( $ this -> routes [ $ route ] , $ params ) ; } if ( ! is_null ( $ ret ) ) { return $ ret ; } ... | Render dispatched route |
7,720 | public function invoke ( $ class , $ action = "index" , $ params = [ ] ) { $ controller = new $ class ( $ this ) ; return \ method_exists ( $ controller , $ action ) && \ is_callable ( [ $ controller , $ action ] ) ? \ call_user_func_array ( [ $ controller , $ action ] , $ params ) : false ; } | Invoke Class as controller |
7,721 | public function getClientIp ( ) { if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { return $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } elseif ( isset ( $ _SERVER [ 'HTTP_CLIENT_IP' ] ) ) { return $ _SERVER [ 'HTTP_CLIENT_IP' ] ; } elseif ( isset ( $ _SERVER [ 'REMOTE_ADDR' ] ) ) { return $ _SERVER [ 'REMOTE_ADDR' ] ... | Get client ip . |
7,722 | public function resolveDependencies ( array $ data ) { $ new_data = array ( ) ; $ original_count = \ count ( $ data ) ; while ( \ count ( $ new_data ) < $ original_count ) { foreach ( $ data as $ name => $ dependencies ) { if ( ! \ count ( $ dependencies ) ) { $ new_data [ ] = $ name ; unset ( $ data [ $ name ] ) ; con... | resolves complicated dependencies to determine what order something can run in |
7,723 | public function url_get_contents ( $ url ) { $ content = '' ; if ( \ function_exists ( 'curl_exec' ) ) { $ conn = \ curl_init ( $ url ) ; \ curl_setopt ( $ conn , CURLOPT_SSL_VERIFYPEER , true ) ; \ curl_setopt ( $ conn , CURLOPT_FRESH_CONNECT , true ) ; \ curl_setopt ( $ conn , CURLOPT_RETURNTRANSFER , 1 ) ; \ curl_se... | Get content from url source . |
7,724 | public function isEmail ( $ email ) { if ( \ function_exists ( 'idn_to_ascii' ) ) { $ email = @ \ idn_to_ascii ( $ email ) ; } return ( bool ) \ filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ; } | Check if string is valid email |
7,725 | public function fixStringBooleanValues ( & $ input ) { if ( ! \ is_array ( $ input ) ) { if ( \ is_string ( $ input ) && ( $ input === 'true' || $ input === 'false' ) ) { $ input = filter_var ( $ input , FILTER_VALIDATE_BOOLEAN ) ; } return $ input ; } foreach ( $ input as $ k => $ v ) { if ( \ is_array ( $ input [ $ k... | Cast boolean string values to boolean |
7,726 | public function fixStringNumericValues ( & $ input ) { if ( ! \ is_array ( $ input ) ) { if ( \ is_string ( $ input ) && \ is_numeric ( $ input ) ) { $ input += 0 ; } return $ input ; } foreach ( $ input as $ k => $ v ) { if ( \ is_array ( $ input [ $ k ] ) ) { $ input [ $ k ] = $ this -> fixStringNumericValues ( $ inp... | Cast numeric string values to numbers |
7,727 | public function retry ( $ times , callable $ fn ) { retrybeginning : try { return $ fn ( ) ; } catch ( \ Exception $ e ) { if ( ! $ times ) { throw new \ Exception ( '' , 0 , $ e ) ; } $ times -- ; goto retrybeginning ; } } | Execute callable with retry if it fails |
7,728 | public function style ( $ assets , $ name , $ path = "" , $ cache = 0 , $ version = false ) { $ path = $ this -> path ( $ path ) ; if ( ! $ path ) return null ; $ href = rtrim ( $ this -> pathToUrl ( $ path ) , '/' ) . "/{$name}.css" . ( $ version ? "?ver={$version}" : "" ) ; $ path .= "/{$name}.css" ; $ tag = '<link h... | Compile styles and return in a link tag |
7,729 | public function style_and_script ( $ assets , $ name , $ path = "" , $ cache = 0 , $ version = false ) { echo $ this -> script ( $ assets , $ name , $ path , $ cache , $ version ) ; echo $ this -> style ( $ assets , $ name , $ path , $ cache , $ version ) ; } | Echo tags for scripts and styles |
7,730 | protected function compile_default_structures ( $ value ) { $ value = preg_replace ( '/(?(R)\((?:[^\(\)]|(?R))*\)|(?<!\w)(\s*)@(if|foreach|for|while)(\s*(?R)+))/' , '$1<?php $2 $3 { ?>' , $ value ) ; $ value = preg_replace ( '/(\s*)@elseif(\s*\(.*\))/' , '$1<?php } elseif$2 { ?>' , $ value ) ; $ value = preg_replace ( ... | Rewrites Lexi s structure openings into PHP structure openings . |
7,731 | public function keys ( $ pattern = null ) { $ keys = array ( ) ; $ stmt = $ this -> connection -> query ( "SELECT `key` FROM " . $ this -> table . " ORDER BY `key`;" ) ; $ res = $ stmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; if ( ! $ pattern ) { foreach ( $ res as $ record ) { $ keys [ ] = $ record [ "key" ] ; } } else ... | Get all keys matching a pattern |
7,732 | public function registerCriteriaFunction ( $ criteria ) { $ id = \ uniqid ( 'criteria' ) ; if ( \ is_callable ( $ criteria ) ) { $ this -> document_criterias [ $ id ] = $ criteria ; return $ id ; } if ( is_array ( $ criteria ) ) { $ fn = null ; eval ( '$fn = function($document) { return ' . UtilArrayQuery :: buildCondi... | Register Criteria function |
7,733 | public function callCriteriaFunction ( $ id , $ document ) { return isset ( $ this -> document_criterias [ $ id ] ) ? $ this -> document_criterias [ $ id ] ( $ document ) : false ; } | Execute registred criteria function |
7,734 | public function getCollectionNames ( ) { $ stmt = $ this -> connection -> query ( "SELECT name FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence';" ) ; $ tables = $ stmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; $ names = [ ] ; foreach ( $ tables as $ table ) { $ names [ ] = $ table [ 'name' ] ; } return $ ... | Get all collection names in the database |
7,735 | public function listCollections ( ) { foreach ( $ this -> getCollectionNames ( ) as $ name ) { if ( ! isset ( $ this -> collections [ $ name ] ) ) { $ this -> collections [ $ name ] = new Collection ( $ name , $ this ) ; } } return $ this -> collections ; } | Get all collections in the database |
7,736 | public function set ( $ name , $ value , $ ttl = 86400 , $ path = '/' , $ domain = '' , $ secure = false , $ http_only = false ) { $ this -> _cookies [ $ name ] = $ value ; $ result = \ setcookie ( $ name , $ value , time ( ) + $ ttl , $ path , $ domain , $ secure , $ http_only ) ; if ( isset ( $ this -> _deleted_cooki... | sets a cookie |
7,737 | public function get ( $ name ) { if ( isset ( $ this -> _deleted_cookies [ $ name ] ) ) { return null ; } if ( \ array_key_exists ( $ name , $ this -> _cookies ) ) { return $ this -> _cookies [ $ name ] ; } $ value = isset ( $ _COOKIE [ $ name ] ) ? $ _COOKIE [ $ name ] : null ; $ this -> _cookies [ $ name ] = $ value ... | gets a cookie |
7,738 | public function delete ( $ name , $ path = '/' , $ domain = '' , $ secure = false , $ http_only = false ) { $ success = $ this -> set ( $ name , null , - 10 , $ path , $ domain , $ secure , $ http_only ) ; $ this -> _deleted_cookies [ $ name ] = $ name ; if ( isset ( $ this -> _cookies [ $ name ] ) ) { unset ( $ this -... | deletes a cookie |
7,739 | public function getAndDelete ( $ name , $ path = '/' , $ domain = '' , $ secure = false , $ http_only = false ) { $ value = $ this -> get ( $ name ) ; $ this -> delete ( $ name , $ path , $ domain , $ secure , $ http_only ) ; return $ value ; } | gets a cookie and eats it |
7,740 | protected function getData ( ) { $ sql = [ 'SELECT document FROM ' . $ this -> collection -> name ] ; if ( $ this -> criteria ) { $ sql [ ] = 'WHERE document_criteria("' . $ this -> criteria . '", document)' ; } if ( $ this -> sort ) { $ orders = [ ] ; foreach ( $ this -> sort as $ field => $ direction ) { $ orders [ ]... | Get documents matching criteria |
7,741 | public function get ( $ key , $ alternative = null , $ lang = null ) { if ( ! $ lang ) { $ lang = $ this -> locale ; } if ( ! $ alternative ) { $ alternative = $ key ; } return isset ( $ this -> _languages [ $ lang ] [ $ key ] ) ? $ this -> _languages [ $ lang ] [ $ key ] : $ alternative ; } | Get translated string by key |
7,742 | public function getstr ( $ key , $ params = [ ] , $ alternative = null , $ lang = null ) { if ( ! $ lang ) { $ lang = $ this -> locale ; } if ( ! $ alternative ) { $ alternative = $ key ; } return \ vsprintf ( isset ( $ this -> _languages [ $ lang ] [ $ key ] ) ? $ this -> _languages [ $ lang ] [ $ key ] : $ alternativ... | Get translated string by key and params |
7,743 | public function load ( $ langfile , $ lang = null ) { if ( ! $ lang ) { $ lang = $ this -> locale ; } if ( $ path = $ this -> app -> path ( $ langfile ) ) { if ( ! isset ( $ this -> _languages [ $ lang ] ) ) { $ this -> _languages [ $ lang ] = [ ] ; } $ langtable = include ( $ path ) ; $ this -> _languages [ $ lang ] =... | Load language files |
7,744 | public function data ( $ lang = null ) { if ( $ lang ) { return isset ( $ this -> _languages [ $ lang ] ) ? $ this -> _languages [ $ lang ] : [ ] ; } return $ this -> _languages ; } | Get language data |
7,745 | public function hincrby ( $ collection , $ key , $ field , $ by = 1 ) { $ current = $ this -> hget ( $ collection , $ key , $ field , 0 ) ; $ newone = $ current + $ by ; $ this -> hset ( $ collection , $ key , $ field , $ newone ) ; return $ newone ; } | Increment the integer value of a hash field by the given number |
7,746 | public function hmget ( $ key ) { $ set = $ this -> getKey ( $ collection , $ key , [ ] ) ; $ fields = func_get_args ( ) ; $ values = [ ] ; for ( $ i = 1 ; $ i < count ( $ fields ) ; $ i ++ ) { $ field = $ fields [ $ i ] ; $ values [ ] = isset ( $ set [ $ field ] ) ? $ set [ $ field ] : null ; } return $ values ; } | Get the values of all the given hash fields |
7,747 | public function offsetSet ( $ key , $ value ) { if ( strpos ( $ key , '/' ) ) { $ keys = explode ( '/' , $ key ) ; $ mem = $ this -> props ; foreach ( $ keys as $ keyname ) { if ( ! isset ( $ mem [ $ keyname ] ) ) { $ mem [ $ keyname ] = new ArrayObject ( [ ] ) ; } $ mem = & $ mem [ $ keyname ] ; } $ mem = $ value ; } ... | Array Access implementation |
7,748 | public function findForUser ( $ id , $ userId ) { return Passport :: token ( ) -> where ( 'id' , $ id ) -> where ( 'user_id' , $ userId ) -> first ( ) ; } | Get a token by the given user ID and token ID . |
7,749 | public function findValidToken ( $ user , $ client ) { return $ client -> tokens ( ) -> whereUserId ( $ user -> getKey ( ) ) -> where ( 'revoked' , 0 ) -> where ( 'expires_at' , '>' , Carbon :: now ( ) ) -> latest ( 'expires_at' ) -> first ( ) ; } | Find a valid token for the given user and client . |
7,750 | protected function createClientCredentialsClient ( ClientRepository $ clients ) { $ name = $ this -> option ( 'name' ) ? : $ this -> ask ( 'What should we name the client?' , config ( 'app.name' ) . ' ClientCredentials Grant Client' ) ; $ client = $ clients -> create ( null , $ name , '' ) ; $ this -> info ( 'New clien... | Create a client credentials grant client . |
7,751 | protected function outputClientDetails ( Client $ client ) { $ this -> line ( '<comment>Client ID:</comment> ' . $ client -> id ) ; $ this -> line ( '<comment>Client secret:</comment> ' . $ client -> secret ) ; } | Output the client s ID and secret key . |
7,752 | public function make ( $ userId , $ csrfToken ) { $ config = $ this -> config -> get ( 'session' ) ; $ expiration = Carbon :: now ( ) -> addMinutes ( $ config [ 'lifetime' ] ) ; return new Cookie ( Passport :: cookie ( ) , $ this -> createToken ( $ userId , $ csrfToken , $ expiration ) , $ expiration , $ config [ 'path... | Create a new API token cookie . |
7,753 | protected function createToken ( $ userId , $ csrfToken , Carbon $ expiration ) { return JWT :: encode ( [ 'sub' => $ userId , 'csrf' => $ csrfToken , 'expiry' => $ expiration -> getTimestamp ( ) , ] , $ this -> encrypter -> getKey ( ) ) ; } | Create a new JWT token for the given user ID and CSRF token . |
7,754 | public function make ( $ userId , $ name , array $ scopes = [ ] ) { $ response = $ this -> dispatchRequestToAuthorizationServer ( $ this -> createRequest ( $ this -> clients -> personalAccessClient ( ) , $ userId , $ scopes ) ) ; $ token = tap ( $ this -> findAccessToken ( $ response ) , function ( $ token ) use ( $ us... | Create a new personal access token . |
7,755 | protected function dispatchRequestToAuthorizationServer ( ServerRequest $ request ) { return json_decode ( $ this -> server -> respondToAccessTokenRequest ( $ request , new Response ) -> getBody ( ) -> __toString ( ) , true ) ; } | Dispatch the given request to the authorization server . |
7,756 | protected function findAccessToken ( array $ response ) { return $ this -> tokens -> find ( $ this -> jwt -> parse ( $ response [ 'access_token' ] ) -> getClaim ( 'jti' ) ) ; } | Get the access token instance for the parsed response . |
7,757 | public function refresh ( Request $ request ) { return ( new Response ( 'Refreshed.' ) ) -> withCookie ( $ this -> cookieFactory -> make ( $ request -> user ( ) -> getKey ( ) , $ request -> session ( ) -> token ( ) ) ) ; } | Get a fresh transient token cookie for the authenticated user . |
7,758 | protected function getAuthRequestFromSession ( Request $ request ) { return tap ( $ request -> session ( ) -> get ( 'authRequest' ) , function ( $ authRequest ) use ( $ request ) { if ( ! $ authRequest ) { throw new Exception ( 'Authorization request was not present in the session.' ) ; } $ authRequest -> setUser ( new... | Get the authorization request from the session . |
7,759 | protected function registerAuthorizationServer ( ) { $ this -> app -> singleton ( AuthorizationServer :: class , function ( ) { return tap ( $ this -> makeAuthorizationServer ( ) , function ( $ server ) { $ server -> setDefaultScope ( Passport :: $ defaultScope ) ; $ server -> enableGrantType ( $ this -> makeAuthCodeGr... | Register the authorization server . |
7,760 | protected function buildAuthCodeGrant ( ) { return new AuthCodeGrant ( $ this -> app -> make ( Bridge \ AuthCodeRepository :: class ) , $ this -> app -> make ( Bridge \ RefreshTokenRepository :: class ) , new DateInterval ( 'PT10M' ) ) ; } | Build the Auth Code grant instance . |
7,761 | protected function makeRefreshTokenGrant ( ) { $ repository = $ this -> app -> make ( RefreshTokenRepository :: class ) ; return tap ( new RefreshTokenGrant ( $ repository ) , function ( $ grant ) { $ grant -> setRefreshTokenTTL ( Passport :: refreshTokensExpireIn ( ) ) ; } ) ; } | Create and configure a Refresh Token grant instance . |
7,762 | protected function makeCryptKey ( $ type ) { $ key = str_replace ( '\\n' , "\n" , $ this -> app -> make ( Config :: class ) -> get ( 'passport.' . $ type . '_key' ) ) ; if ( ! $ key ) { $ key = 'file://' . Passport :: keyPath ( 'oauth-' . $ type . '.key' ) ; } return new CryptKey ( $ key , null , false ) ; } | Create a CryptKey instance without permissions check . |
7,763 | protected function registerGuard ( ) { Auth :: extend ( 'passport' , function ( $ app , $ name , array $ config ) { return tap ( $ this -> makeGuard ( $ config ) , function ( $ guard ) { $ this -> app -> refresh ( 'request' , $ guard , 'setRequest' ) ; } ) ; } ) ; } | Register the token guard . |
7,764 | protected function makeGuard ( array $ config ) { return new RequestGuard ( function ( $ request ) use ( $ config ) { return ( new TokenGuard ( $ this -> app -> make ( ResourceServer :: class ) , Auth :: createUserProvider ( $ config [ 'provider' ] ) , $ this -> app -> make ( TokenRepository :: class ) , $ this -> app ... | Make an instance of the token guard . |
7,765 | protected function deleteCookieOnLogout ( ) { Event :: listen ( Logout :: class , function ( ) { if ( Request :: hasCookie ( Passport :: cookie ( ) ) ) { Cookie :: queue ( Cookie :: forget ( Passport :: cookie ( ) ) ) ; } } ) ; } | Register the cookie deletion event handler . |
7,766 | public function forUser ( Request $ request ) { $ tokens = $ this -> tokenRepository -> forUser ( $ request -> user ( ) -> getKey ( ) ) ; return $ tokens -> load ( 'client' ) -> filter ( function ( $ token ) { return ! $ token -> client -> firstParty ( ) && ! $ token -> revoked ; } ) -> values ( ) ; } | Get all of the authorized tokens for the authenticated user . |
7,767 | public function destroy ( Request $ request , $ tokenId ) { $ token = $ this -> tokenRepository -> findForUser ( $ tokenId , $ request -> user ( ) -> getKey ( ) ) ; if ( is_null ( $ token ) ) { return new Response ( '' , 404 ) ; } $ token -> revoke ( ) ; return new Response ( '' , Response :: HTTP_NO_CONTENT ) ; } | Delete the given token . |
7,768 | public function user ( Request $ request ) { if ( $ request -> bearerToken ( ) ) { return $ this -> authenticateViaBearerToken ( $ request ) ; } elseif ( $ request -> cookie ( Passport :: cookie ( ) ) ) { return $ this -> authenticateViaCookie ( $ request ) ; } } | Get the user for the incoming request . |
7,769 | public function client ( Request $ request ) { if ( $ request -> bearerToken ( ) ) { if ( ! $ psr = $ this -> getPsrRequestViaBearerToken ( $ request ) ) { return ; } return $ this -> clients -> findActive ( $ psr -> getAttribute ( 'oauth_client_id' ) ) ; } elseif ( $ request -> cookie ( Passport :: cookie ( ) ) ) { if... | Get the client for the incoming request . |
7,770 | protected function getPsrRequestViaBearerToken ( $ request ) { $ psr = ( new DiactorosFactory ) -> createRequest ( $ request ) ; try { return $ this -> server -> validateAuthenticatedRequest ( $ psr ) ; } catch ( OAuthServerException $ e ) { $ request -> headers -> set ( 'Authorization' , '' , true ) ; Container :: get... | Authenticate and get the incoming PSR - 7 request via the Bearer token . |
7,771 | protected function getTokenViaCookie ( $ request ) { try { $ token = $ this -> decodeJwtTokenCookie ( $ request ) ; } catch ( Exception $ e ) { return ; } if ( ! Passport :: $ ignoreCsrfToken && ( ! $ this -> validCsrf ( $ token , $ request ) || time ( ) >= $ token [ 'expiry' ] ) ) { return ; } return $ token ; } | Get the token cookie via the incoming request . |
7,772 | public function find ( $ id ) { $ client = Passport :: client ( ) ; return $ client -> where ( $ client -> getKeyName ( ) , $ id ) -> first ( ) ; } | Get a client by the given ID . |
7,773 | public function findActive ( $ id ) { $ client = $ this -> find ( $ id ) ; return $ client && ! $ client -> revoked ? $ client : null ; } | Get an active client by the given ID . |
7,774 | public function findForUser ( $ clientId , $ userId ) { $ client = Passport :: client ( ) ; return $ client -> where ( $ client -> getKeyName ( ) , $ clientId ) -> where ( 'user_id' , $ userId ) -> first ( ) ; } | Get a client instance for the given ID and user ID . |
7,775 | public function activeForUser ( $ userId ) { return $ this -> forUser ( $ userId ) -> reject ( function ( $ client ) { return $ client -> revoked ; } ) -> values ( ) ; } | Get the active client instances for the given user ID . |
7,776 | public function createPasswordGrantClient ( $ userId , $ name , $ redirect ) { return $ this -> create ( $ userId , $ name , $ redirect , false , true ) ; } | Store a new password grant client . |
7,777 | public function revoked ( $ id ) { $ client = $ this -> find ( $ id ) ; return is_null ( $ client ) || $ client -> revoked ; } | Determine if the given client is revoked . |
7,778 | public function forUser ( Request $ request ) { $ userId = $ request -> user ( ) -> getKey ( ) ; return $ this -> clients -> activeForUser ( $ userId ) -> makeVisible ( 'secret' ) ; } | Get all of the clients for the authenticated user . |
7,779 | public function can ( $ scope ) { return in_array ( '*' , $ this -> scopes ) || array_key_exists ( $ scope , array_flip ( $ this -> scopes ) ) ; } | Determine if the token has a given scope . |
7,780 | public function all ( ) { $ this -> forAuthorization ( ) ; $ this -> forAccessTokens ( ) ; $ this -> forTransientTokens ( ) ; $ this -> forClients ( ) ; $ this -> forPersonalAccessTokens ( ) ; } | Register routes for transient tokens clients and personal access tokens . |
7,781 | protected function parseScopes ( $ authRequest ) { return Passport :: scopesFor ( collect ( $ authRequest -> getScopes ( ) ) -> map ( function ( $ scope ) { return $ scope -> getIdentifier ( ) ; } ) -> unique ( ) -> all ( ) ) ; } | Transform the authorization requests s scopes into Scope instances . |
7,782 | protected function alreadyContainsToken ( $ response ) { foreach ( $ response -> headers -> getCookies ( ) as $ cookie ) { if ( $ cookie -> getName ( ) === Passport :: cookie ( ) ) { return true ; } } return false ; } | Determine if the given response already contains an API token . |
7,783 | public static function scopes ( ) { return collect ( static :: $ scopes ) -> map ( function ( $ description , $ id ) { return new Scope ( $ id , $ description ) ; } ) -> values ( ) ; } | Get all of the scopes defined for the application . |
7,784 | public static function refreshTokensExpireIn ( DateTimeInterface $ date = null ) { if ( is_null ( $ date ) ) { return static :: $ refreshTokensExpireAt ? Carbon :: now ( ) -> diff ( static :: $ refreshTokensExpireAt ) : new DateInterval ( 'P1Y' ) ; } static :: $ refreshTokensExpireAt = $ date ; return new static ; } | Get or set when refresh tokens expire . |
7,785 | public static function personalAccessTokensExpireIn ( DateTimeInterface $ date = null ) { if ( is_null ( $ date ) ) { return static :: $ personalAccessTokensExpireAt ? Carbon :: now ( ) -> diff ( static :: $ personalAccessTokensExpireAt ) : new DateInterval ( 'P1Y' ) ; } static :: $ personalAccessTokensExpireAt = $ dat... | Get or set when personal access tokens expire . |
7,786 | public static function keyPath ( $ file ) { $ file = ltrim ( $ file , '/\\' ) ; return static :: $ keyPath ? rtrim ( static :: $ keyPath , '/\\' ) . DIRECTORY_SEPARATOR . $ file : storage_path ( $ file ) ; } | The location of the encryption keys . |
7,787 | private function closeCurlHandle ( ) { if ( ! is_null ( $ this -> curlHandle ) ) { curl_close ( $ this -> curlHandle ) ; $ this -> curlHandle = null ; } } | Closes the curl handle if initialized . Do nothing if already closed . |
7,788 | private function resetCurlHandle ( ) { if ( ! is_null ( $ this -> curlHandle ) && $ this -> getEnablePersistentConnections ( ) ) { curl_reset ( $ this -> curlHandle ) ; } else { $ this -> initCurlHandle ( ) ; } } | Resets the curl handle . If the handle is not already initialized or if persistent connections are disabled the handle is reinitialized instead . |
7,789 | private function hasHeader ( $ headers , $ name ) { foreach ( $ headers as $ header ) { if ( strncasecmp ( $ header , "{$name}: " , strlen ( $ name ) + 2 ) === 0 ) { return true ; } } return false ; } | Checks if a list of headers contains a specific header name . |
7,790 | public static function constructEvent ( $ payload , $ sigHeader , $ secret , $ tolerance = self :: DEFAULT_TOLERANCE ) { $ data = json_decode ( $ payload , true ) ; $ jsonError = json_last_error ( ) ; if ( $ data === null && $ jsonError !== JSON_ERROR_NONE ) { $ msg = "Invalid payload: $payload " . "(json_last_error() ... | Returns an Event instance using the provided JSON payload . Throws a \ UnexpectedValueException if the payload is not valid JSON and a \ Stripe \ SignatureVerificationException if the signature verification fails for any reason . |
7,791 | public static function verifyHeader ( $ payload , $ header , $ secret , $ tolerance = null ) { $ timestamp = self :: getTimestamp ( $ header ) ; $ signatures = self :: getSignatures ( $ header , self :: EXPECTED_SCHEME ) ; if ( $ timestamp == - 1 ) { throw new Error \ SignatureVerification ( "Unable to extract timestam... | Verifies the signature header sent by Stripe . Throws a SignatureVerification exception if the verification fails for any reason . |
7,792 | private static function getTimestamp ( $ header ) { $ items = explode ( "," , $ header ) ; foreach ( $ items as $ item ) { $ itemParts = explode ( "=" , $ item , 2 ) ; if ( $ itemParts [ 0 ] == "t" ) { if ( ! is_numeric ( $ itemParts [ 1 ] ) ) { return - 1 ; } return intval ( $ itemParts [ 1 ] ) ; } } return - 1 ; } | Extracts the timestamp in a signature header . |
7,793 | private static function getSignatures ( $ header , $ scheme ) { $ signatures = [ ] ; $ items = explode ( "," , $ header ) ; foreach ( $ items as $ item ) { $ itemParts = explode ( "=" , $ item , 2 ) ; if ( $ itemParts [ 0 ] == $ scheme ) { array_push ( $ signatures , $ itemParts [ 1 ] ) ; } } return $ signatures ; } | Extracts the signatures matching a given scheme in a signature header . |
7,794 | public static function constructFrom ( $ values , $ opts = null ) { $ obj = new static ( isset ( $ values [ 'id' ] ) ? $ values [ 'id' ] : null ) ; $ obj -> refreshFrom ( $ values , $ opts ) ; return $ obj ; } | This unfortunately needs to be public to be used in Util \ Util |
7,795 | public function updateAttributes ( $ values , $ opts = null , $ dirty = true ) { foreach ( $ values as $ k => $ v ) { if ( ( $ k === "metadata" ) && ( is_array ( $ v ) ) ) { $ this -> _values [ $ k ] = StripeObject :: constructFrom ( $ v , $ opts ) ; } else { $ this -> _values [ $ k ] = Util \ Util :: convertToStripeOb... | Mass assigns attributes on the model . |
7,796 | public function dirty ( ) { $ this -> _unsavedValues = new Util \ Set ( array_keys ( $ this -> _values ) ) ; foreach ( $ this -> _values as $ k => $ v ) { $ this -> dirtyValue ( $ v ) ; } } | Sets all keys within the StripeObject as unsaved so that they will be included with an update when serializeParameters is called . This method is also recursive so any StripeObjects contained as values or which are values in a tenant array are also marked as dirty . |
7,797 | protected static function deepCopy ( $ obj ) { if ( is_array ( $ obj ) ) { $ copy = [ ] ; foreach ( $ obj as $ k => $ v ) { $ copy [ $ k ] = self :: deepCopy ( $ v ) ; } return $ copy ; } elseif ( $ obj instanceof StripeObject ) { return $ obj :: constructFrom ( self :: deepCopy ( $ obj -> _values ) , clone $ obj -> _o... | Produces a deep copy of the given object including support for arrays and StripeObjects . |
7,798 | public static function emptyValues ( $ obj ) { if ( is_array ( $ obj ) ) { $ values = $ obj ; } elseif ( $ obj instanceof StripeObject ) { $ values = $ obj -> _values ; } else { throw new \ InvalidArgumentException ( "empty_values got got unexpected object type: " . get_class ( $ obj ) ) ; } $ update = array_fill_keys ... | Returns a hash of empty values for all the values that are in the given StripeObject . |
7,799 | public static function convertStripeObjectToArray ( $ values ) { $ results = [ ] ; foreach ( $ values as $ k => $ v ) { if ( $ k [ 0 ] == '_' ) { continue ; } if ( $ v instanceof StripeObject ) { $ results [ $ k ] = $ v -> __toArray ( true ) ; } elseif ( is_array ( $ v ) ) { $ results [ $ k ] = self :: convertStripeObj... | Recursively converts the PHP Stripe object to an array . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.