idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
52,800
|
protected function fetchProviderData ( $ url , array $ headers = [ ] ) { $ client = $ this -> getProvider ( ) -> getHttpClient ( ) ; $ client -> setBaseUrl ( $ url ) ; if ( $ headers ) { $ client -> setDefaultOption ( 'headers' , $ headers ) ; } $ request = $ client -> get ( ) -> send ( ) ; $ response = $ request -> getBody ( ) ; return $ response ; }
|
Fetch provider data
|
52,801
|
public function getRedirectUri ( ) { $ addTrailingSlashesToUrls = \ Craft \ craft ( ) -> config -> get ( 'addTrailingSlashesToUrls' ) ; \ Craft \ craft ( ) -> config -> set ( 'addTrailingSlashesToUrls' , false ) ; $ redirectUri = \ Craft \ UrlHelper :: getActionUrl ( 'oauth/connect' ) ; \ Craft \ craft ( ) -> config -> set ( 'addTrailingSlashesToUrls' , $ addTrailingSlashesToUrls ) ; $ redirectUri = str_replace ( \ Craft \ craft ( ) -> config -> get ( 'cpTrigger' ) . '/' , '' , $ redirectUri ) ; OauthPlugin :: log ( 'Redirect URI: ' . $ redirectUri , LogLevel :: Info ) ; return $ redirectUri ; }
|
Returns the redirect URI
|
52,802
|
public static function handle ( $ resourceName , $ response , $ statusCode ) { switch ( $ statusCode ) { case Response :: HTTP_UNAUTHORIZED : return new PaystackUnauthorizedException ( $ response , $ statusCode ) ; case Response :: HTTP_NOT_FOUND : return new PaystackNotFoundException ( $ response , $ statusCode ) ; case Response :: HTTP_BAD_REQUEST : return new PaystackValidationException ( $ response , $ statusCode ) ; case Response :: HTTP_GATEWAY_TIMEOUT : return new PaystackInternalServerError ( $ response , $ statusCode ) ; case Response :: HTTP_INTERNAL_SERVER_ERROR : return new PaystackInternalServerError ( 'Internal Server Error.' , $ statusCode ) ; default : return new \ Exception ( 'Unknown Error Occurred.' , $ statusCode ) ; } }
|
Handles errors encountered and returns the kind of exception they are .
|
52,803
|
protected function defaultListeners ( ) { $ this -> addListener ( 'parser.crawler.before' , new TagsInScriptListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new ExcludeBlocksListener ( ) , 1 ) ; $ this -> addListener ( 'parser.crawler.after' , new DomTextListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new DomButtonListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new DomIframeSrcListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new DomImgListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new DomInputDataListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new DomInputRadioListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new DomLinkListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new DomMetaContentListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new DomPlaceholderListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new DomSpanListener ( ) ) ; $ this -> addListener ( 'parser.crawler.after' , new DomTableDataListener ( ) ) ; $ this -> addListener ( 'parser.translated' , new DomReplaceListener ( ) ) ; $ this -> addListener ( 'parser.render' , new CleanHtmlEntitiesListener ( ) ) ; $ this -> addListener ( 'parser.render' , new TagsInScriptListener ( false ) ) ; }
|
Add default listeners
|
52,804
|
public function makeRequest ( $ method , $ endpoint , $ body = [ ] , $ asArray = true ) { try { list ( $ rawBody , $ httpStatusCode , $ httpHeader ) = $ this -> getHttpClient ( ) -> request ( $ method , $ this -> makeAbsUrl ( $ endpoint ) , [ 'api_key' => $ this -> apiKey ] , $ body ) ; $ array = json_decode ( $ rawBody , true ) ; } catch ( \ Exception $ e ) { throw new ApiError ( $ e -> getMessage ( ) , $ body ) ; } if ( $ asArray ) { return $ array ; } return [ $ rawBody , $ httpStatusCode , $ httpHeader ] ; }
|
Make the API call and return the response .
|
52,805
|
public function createProvider ( ) { $ graphApiVersion = 'v2.12' ; if ( ! empty ( $ this -> providerInfos -> config [ 'graphApiVersion' ] ) ) { $ graphApiVersion = $ this -> providerInfos -> config [ 'graphApiVersion' ] ; } $ config = [ 'clientId' => $ this -> providerInfos -> clientId , 'clientSecret' => $ this -> providerInfos -> clientSecret , 'redirectUri' => $ this -> getRedirectUri ( ) , 'graphApiVersion' => $ graphApiVersion ] ; return new \ League \ OAuth2 \ Client \ Provider \ Facebook ( $ config ) ; }
|
Create Facebook Provider
|
52,806
|
public function getAll ( $ page = '' ) { $ page = ! empty ( $ page ) ? "/page={$page}" : '' ; $ request = $ this -> paystackHttpClient -> get ( $ this -> transformUrl ( Resource :: GET_TRANSACTION , '' ) . $ page ) ; return $ this -> processResourceRequestResponse ( $ request ) ; }
|
Get all transactions .
|
52,807
|
public function getTransactionTotals ( ) { $ request = $ this -> paystackHttpClient -> get ( Resource :: GET_TRANSACTION_TOTALS ) ; return $ this -> processResourceRequestResponse ( $ request ) ; }
|
Get transactions totals .
|
52,808
|
public function verify ( $ reference ) { $ request = $ this -> paystackHttpClient -> get ( $ this -> transformUrl ( Resource :: VERIFY_TRANSACTION , $ reference , ':reference' ) ) ; return $ this -> processResourceRequestResponse ( $ request ) ; }
|
Verify Transaction by transaction reference .
|
52,809
|
public function initialize ( $ body ) { $ request = $ this -> paystackHttpClient -> post ( Resource :: INITIALIZE_TRANSACTION , [ 'body' => is_array ( $ body ) ? $ this -> toJson ( $ body ) : $ body , ] ) ; return $ this -> processResourceRequestResponse ( $ request ) ; }
|
Initialize one time transaction .
|
52,810
|
public function chargeAuthorization ( $ body ) { $ request = $ this -> paystackHttpClient -> post ( Resource :: CHARGE_AUTHORIZATION , [ 'body' => is_array ( $ body ) ? $ this -> toJson ( $ body ) : $ body , ] ) ; return $ this -> processResourceRequestResponse ( $ request ) ; }
|
charge returning transaction .
|
52,811
|
public function chargeToken ( $ body ) { $ request = $ this -> paystackHttpClient -> post ( Resource :: CHARGE_TOKEN , [ 'body' => is_array ( $ body ) ? $ this -> toJson ( $ body ) : $ body , ] ) ; return $ this -> processResourceRequestResponse ( $ request ) ; }
|
Charge Token .
|
52,812
|
public function createProvider ( ) { if ( $ this -> providerInfos -> clientId && $ this -> providerInfos -> clientSecret ) { $ config = [ 'identifier' => $ this -> providerInfos -> clientId , 'secret' => $ this -> providerInfos -> clientSecret , 'callback_uri' => $ this -> getRedirectUri ( ) , ] ; return new \ League \ OAuth1 \ Client \ Server \ Twitter ( $ config ) ; } }
|
Create Twitter Provider
|
52,813
|
public function processResourceRequestResponse ( ResponseInterface $ request ) { $ response = json_decode ( $ request -> getBody ( ) -> getContents ( ) ) ; if ( Response :: HTTP_OK !== $ request -> getStatusCode ( ) && Response :: HTTP_CREATED !== $ request -> getStatusCode ( ) ) { return ExceptionHandler :: handle ( get_class ( $ this ) , $ response , $ request -> getStatusCode ( ) ) ; } return ( isset ( $ response -> data ) ) ? json_decode ( json_encode ( $ response -> data ) , true ) : json_decode ( json_encode ( $ response ) , true ) ; }
|
Checks request response and dispatch result to appropriate handler .
|
52,814
|
public function setType ( $ type ) { if ( ! ( $ type >= WordType :: __MIN && $ type <= WordType :: __MAX ) ) { throw new InvalidWordTypeException ( ) ; } $ this -> type = $ type ; return $ this ; }
|
Set type of word you gonna translate . Returns false if type is incorrect .
|
52,815
|
private function processMethod ( $ method , array $ options , array $ headers , array $ body = [ ] ) { if ( $ method === 'get' ) { if ( $ body !== [ ] ) { throw new \ Exception ( 'Issuing a GET request with a body' ) ; } $ options [ CURLOPT_HTTPGET ] = 1 ; } elseif ( $ method === 'post' ) { $ data_string = json_encode ( $ body ) ; $ options [ CURLOPT_POST ] = 1 ; $ options [ CURLOPT_POSTFIELDS ] = $ data_string ; array_push ( $ headers , 'Content-Type: application/json' ) ; array_push ( $ headers , 'Content-Length: ' . strlen ( $ data_string ) ) ; } else { throw new \ Exception ( 'Unrecognized method ' . strtoupper ( $ method ) ) ; } return [ $ options , $ headers ] ; }
|
Setup behavior for each methods
|
52,816
|
public function getValidationErrors ( ) { $ errors = [ ] ; if ( isset ( $ this -> response -> errors ) ) { foreach ( $ this -> response -> errors as $ error => $ reasons ) { $ errors [ ] = [ 'attribute' => $ error , 'reason' => $ this -> getValidationReasonsAsString ( $ reasons ) , ] ; } } return $ errors ; }
|
Get validation errors that occurred in requests .
|
52,817
|
public static function getGuzzleClient ( ) { if ( ! isset ( self :: $ guzzleClient ) || is_null ( self :: $ guzzleClient ) ) { self :: $ guzzleClient = new Client ( array ( 'timeout' => Config :: TIMEOUT , 'connection_timeout' => Config :: CONN_TIMEOUT , 'verify' => Config :: $ IS_LIVE ) ) ; } return self :: $ guzzleClient ; }
|
Enforces the use of a single connection
|
52,818
|
public function getAll ( $ page = null ) { $ page = ! empty ( $ page ) ? "page={$page}" : '' ; $ request = $ this -> paystackHttpClient -> get ( $ this -> transformUrl ( Resource :: CUSTOMERS_URL , '' ) . $ page ) ; return $ this -> processResourceRequestResponse ( $ request ) ; }
|
Get all customer . per page .
|
52,819
|
public function save ( $ body ) { $ request = $ this -> paystackHttpClient -> post ( $ this -> transformUrl ( Resource :: CUSTOMERS_URL , '' ) , [ 'body' => is_array ( $ body ) ? $ this -> toJson ( $ body ) : $ body , ] ) ; return $ this -> processResourceRequestResponse ( $ request ) ; }
|
create new customer .
|
52,820
|
public function update ( $ id , $ body ) { $ request = $ this -> paystackHttpClient -> put ( $ this -> transformUrl ( Resource :: CUSTOMERS_URL , $ id ) , [ 'body' => is_array ( $ body ) ? $ this -> toJson ( $ body ) : $ body , ] ) ; return $ this -> processResourceRequestResponse ( $ request ) ; }
|
update customer .
|
52,821
|
public function getPlan ( $ planCode ) { $ plan = $ this -> planResource -> get ( $ planCode ) ; if ( $ plan instanceof \ Exception ) { throw $ plan ; } $ this -> setDeletable ( true ) ; return $ this -> _setAttributes ( $ plan ) ; }
|
Get plan by plan code .
|
52,822
|
public function make ( $ name , $ description , $ amount , $ currency , array $ otherAttributes = [ ] ) { $ this -> name = $ name ; $ this -> description = $ description ; $ this -> amount = $ amount ; $ this -> currency = $ currency ; $ this -> _setAttributes ( $ otherAttributes ) ; $ this -> setCreatable ( true ) ; return $ this ; }
|
Create new Plan Object .
|
52,823
|
public function transform ( $ transformMode = '' ) { $ planObject = [ 'plan_code' => $ this -> plan_code , 'name' => $ this -> name , 'description' => $ this -> description , 'amount' => $ this -> amount , 'interval' => $ this -> interval , 'currency' => $ this -> currency , 'hosted_page' => $ this -> hosted_page , 'hosted_page_url' => $ this -> hosted_page_url , 'hosted_page_summary' => $ this -> hosted_page_summary , 'subscription_count' => count ( $ this -> subscriptions ) , ] ; switch ( $ transformMode ) { case ModelInterface :: TRANSFORM_TO_JSON_ARRAY : return json_encode ( $ planObject ) ; default : return $ planObject ; } }
|
Outward presentation of object .
|
52,824
|
public static function make ( $ authorization , $ amount , $ email , $ plan ) { return new static ( self :: generateTransactionRef ( ) , $ authorization , $ amount , $ email , $ plan ) ; }
|
Create a new returning transaction object .
|
52,825
|
public function charge ( ) { return ! is_null ( $ this -> transactionRef ) ? $ this -> getTransactionResource ( ) -> chargeAuthorization ( $ this -> _requestPayload ( ) ) : new PaystackInvalidTransactionException ( json_decode ( json_encode ( [ 'message' => 'Transaction Reference Not Generated.' , ] ) , false ) ) ; }
|
Charge returning transaction .
|
52,826
|
public function _requestPayload ( ) { $ payload = [ 'authorization_code' => $ this -> authorization , 'amount' => $ this -> amount , 'reference' => $ this -> transactionRef , 'email' => $ this -> email , ] ; if ( ! empty ( $ this -> plan ) ) { $ payload [ 'plan' ] = $ this -> plan ; } return $ this -> toJson ( $ payload ) ; }
|
Get returning transaction request body .
|
52,827
|
public static function getRealToken ( Oauth_TokenModel $ token ) { $ provider = craft ( ) -> oauth -> getProvider ( $ token -> providerHandle ) ; if ( $ provider ) { switch ( $ provider -> getOauthVersion ( ) ) { case 1 : return $ provider -> createAccessToken ( [ 'identifier' => $ token -> accessToken , 'secret' => $ token -> secret , ] ) ; case 2 : return $ provider -> createAccessToken ( [ 'access_token' => $ token -> accessToken , 'refresh_token' => $ token -> refreshToken , 'secret' => $ token -> secret , 'expires' => $ token -> endOfLife , ] ) ; } } }
|
Get real token
|
52,828
|
public static function realTokenToArray ( $ token ) { $ class = get_class ( $ token ) ; $ tokenArray = array ( 'class' => $ class , ) ; if ( get_class ( $ token ) === 'League\OAuth1\Client\Credentials\TokenCredentials' || is_subclass_of ( $ token , '\League\OAuth1\Client\Credentials\TokenCredentials' ) ) { $ tokenArray [ 'identifier' ] = $ token -> getIdentifier ( ) ; $ tokenArray [ 'secret' ] = $ token -> getSecret ( ) ; } elseif ( get_class ( $ token ) === 'League\OAuth2\Client\Token\AccessToken' || is_subclass_of ( $ token , '\League\OAuth2\Client\Token\AccessToken' ) ) { $ tokenArray [ 'accessToken' ] = $ token -> getToken ( ) ; $ tokenArray [ 'refreshToken' ] = $ token -> getRefreshToken ( ) ; $ tokenArray [ 'endOfLife' ] = $ token -> getExpires ( ) ; } return $ tokenArray ; }
|
Real token to array
|
52,829
|
public function _setAttributes ( $ attributes ) { if ( is_array ( $ attributes ) ) { foreach ( $ attributes as $ attribute => $ value ) { $ this -> { $ attribute } = $ value ; } return $ this ; } throw new \ InvalidArgumentException ( 'Invalid argument Passed to set attributes on object' ) ; }
|
Set attributes of the model .
|
52,830
|
public function transform ( $ transformMode = '' ) { switch ( $ transformMode ) { case ModelInterface :: TRANSFORM_TO_JSON_ARRAY : return json_encode ( $ this -> objectToArray ( $ this ) ) ; default : return $ this -> objectToArray ( $ this ) ; } }
|
get Outward presentation of object .
|
52,831
|
public function isTranslable ( ) { if ( $ this -> getPath ( ) === null ) { $ this -> detectUrlDetails ( ) ; } foreach ( $ this -> config -> getExcludedUrls ( ) as $ regex ) { $ escapedRegex = Text :: escapeForRegex ( Text :: fullTrim ( $ regex ) ) ; $ fullRegex = sprintf ( '/%s/' , $ escapedRegex ) ; if ( preg_match ( $ fullRegex , $ this -> getPath ( ) ) === 1 ) { return false ; } } return true ; }
|
Check if we need to translate given URL
|
52,832
|
public function detectCurrentLanguage ( ) { $ escapedPathPrefix = Text :: escapeForRegex ( $ this -> config -> getPathPrefix ( ) ) ; $ uriPath = parse_url ( $ this -> config -> getRaw ( ) , PHP_URL_PATH ) ; $ uriPath = preg_replace ( '/^' . $ escapedPathPrefix . '/s' , '' , $ uriPath ) ; $ uriSegments = explode ( '/' , $ uriPath ) ; if ( isset ( $ uriSegments [ 1 ] ) && in_array ( $ uriSegments [ 1 ] , $ this -> translate -> getLanguages ( ) ) ) { return $ uriSegments [ 1 ] ; } return $ this -> translate -> getDefault ( ) ; }
|
Check current locale based on URI segments from the given URL
|
52,833
|
public function detectUrlDetails ( ) { $ escapedPathPrefix = Text :: escapeForRegex ( $ this -> config -> getPathPrefix ( ) ) ; $ languages = implode ( '|' , $ this -> translate -> getLanguages ( ) ) ; $ fullUrl = preg_replace ( '#' . $ escapedPathPrefix . '\/(' . $ languages . ')$#i' , '' , $ this -> getUrl ( ) ) ; $ fullUrl = preg_replace ( '#' . $ escapedPathPrefix . '\/(' . $ languages . ')\/#i' , '/' , $ fullUrl ) ; $ parsed = parse_url ( $ fullUrl ) ; $ this -> host = $ parsed [ 'scheme' ] . '://' . $ parsed [ 'host' ] . ( isset ( $ parsed [ 'port' ] ) ? ':' . $ parsed [ 'port' ] : '' ) ; $ this -> path = isset ( $ parsed [ 'path' ] ) ? $ parsed [ 'path' ] : '/' ; $ this -> query = isset ( $ parsed [ 'query' ] ) ? $ parsed [ 'query' ] : null ; if ( preg_match ( '#^' . $ this -> config -> getPathPrefix ( ) . '#i' , $ this -> path ) ) { $ this -> path = preg_replace ( '#^' . $ this -> config -> getPathPrefix ( ) . '#i' , '' , $ this -> path ) ; } if ( $ this -> path === "" ) { $ this -> path = '/' ; } $ url = $ this -> getHost ( ) . $ this -> getPathPrefix ( ) . $ this -> getPath ( ) ; if ( ! is_null ( $ this -> getQuery ( ) ) ) { $ url .= '?' . $ this -> getQuery ( ) ; } return $ url ; }
|
Generate possible host & base URL then store it into internal variables
|
52,834
|
public function currentRequestAllUrls ( ) { $ urls = $ this -> allUrls ; if ( $ urls === null ) { if ( $ this -> getPath ( ) === null ) { $ this -> detectUrlDetails ( ) ; } $ urls = [ ] ; $ current = $ this -> getHost ( ) . $ this -> config -> getPathPrefix ( ) . $ this -> getPath ( ) ; if ( ! is_null ( $ this -> getQuery ( ) ) ) { $ current .= '?' . $ this -> getQuery ( ) ; } $ urls [ $ this -> translate -> getDefault ( ) ] = $ current ; foreach ( $ this -> translate -> getLanguages ( ) as $ language ) { $ current = $ this -> getHost ( ) . $ this -> config -> getPathPrefix ( ) . '/' . $ language . $ this -> getPath ( ) ; if ( ! is_null ( $ this -> getQuery ( ) ) ) { $ current .= '?' . $ this -> getQuery ( ) ; } $ urls [ $ language ] = $ current ; } $ this -> allUrls = $ urls ; } return $ urls ; }
|
Returns array with all possible URL for current Request
|
52,835
|
public function generateHrefLangsTags ( ) { $ render = '' ; $ urls = $ this -> currentRequestAllUrls ( ) ; foreach ( $ urls as $ language => $ url ) { $ render .= '<link rel="alternate" href="' . $ url . '" hreflang="' . $ language . '"/>' . "\n" ; } return $ render ; }
|
Render hreflang links for SEO
|
52,836
|
public function createProvider ( ) { $ config = [ 'clientId' => $ this -> providerInfos -> clientId , 'clientSecret' => $ this -> providerInfos -> clientSecret , 'redirectUri' => $ this -> getRedirectUri ( ) , ] ; return new \ Dukt \ OAuth2 \ Client \ Provider \ Vimeo ( $ config ) ; }
|
Create Vimeo Provider
|
52,837
|
public function createProvider ( ) { $ config = [ 'clientId' => $ this -> providerInfos -> clientId , 'clientSecret' => $ this -> providerInfos -> clientSecret , 'redirectUri' => $ this -> getRedirectUri ( ) , ] ; return new \ League \ OAuth2 \ Client \ Provider \ Instagram ( $ config ) ; }
|
Creates the provider .
|
52,838
|
public static function transformUrl ( $ url , $ id , $ key = '' ) { return str_replace ( ! empty ( $ key ) ? $ key : ':id' , $ id , $ url ) ; }
|
Transform url by replacing dummy data .
|
52,839
|
public function objectToArray ( $ object ) { if ( ! is_object ( $ object ) && ! is_array ( $ object ) ) { return $ object ; } if ( is_object ( $ object ) ) { $ object = get_object_vars ( $ object ) ; } return array_map ( [ get_class ( ) , 'objectToArray' ] , $ object ) ; }
|
Converts a bowl of object to an array .
|
52,840
|
public function getCustomer ( $ customerId ) { $ customerModel = $ this -> customerResource -> get ( $ customerId ) ; if ( $ customerModel instanceof \ Exception ) { throw $ customerModel ; } $ this -> _setAttributes ( $ customerModel ) ; $ this -> setDeletable ( true ) ; return $ this ; }
|
Get customer by ID .
|
52,841
|
public function make ( $ first_name , $ last_name , $ email , $ phone , $ otherAttributes = [ ] ) { $ this -> first_name = $ first_name ; $ this -> last_name = $ last_name ; $ this -> email = $ email ; $ this -> phone = $ phone ; $ this -> _setAttributes ( $ otherAttributes ) ; $ this -> setCreatable ( true ) ; return $ this ; }
|
set up a new customer object .
|
52,842
|
public function setUpdateData ( $ updateAttributes ) { if ( empty ( $ updateAttributes ) ) { throw new \ InvalidArgumentException ( 'Update Attributes Empty' ) ; } $ this -> _setAttributes ( $ updateAttributes ) ; $ this -> setUpdateable ( true ) ; return $ this ; }
|
set update data on customer model .
|
52,843
|
protected function cleaningHtml ( $ html ) { $ xml = false ; $ childrens = null ; try { $ xml = @ simplexml_load_string ( $ html ) ; } catch ( \ Exception $ e ) { } if ( $ xml !== false ) { if ( ! $ this -> hasHead && $ xml -> getName ( ) === 'head' ) { $ childrens = $ xml -> xpath ( '//head/child::*' ) ; } if ( ! $ this -> hasBody && $ xml -> getName ( ) === 'body' ) { $ childrens = $ xml -> xpath ( '//body/child::*' ) ; } if ( $ childrens !== null ) { $ temp = '' ; foreach ( $ childrens as $ children ) { $ temp .= $ children -> saveXML ( ) ; } $ html = html_entity_decode ( $ temp ) ; } } if ( $ this -> hasHtml ) { $ html = $ this -> htmlMatches [ 'before' ] . $ html . $ this -> htmlMatches [ 'after' ] ; } if ( $ this -> hasDoctype ) { $ html = $ this -> doctypeMatches [ 'content' ] . $ html ; } return $ html ; }
|
Cleaning HTML from parts it should not contains
|
52,844
|
public function getCustomers ( $ page = '' ) { $ customerObjects = [ ] ; $ customers = $ this -> getCustomerResource ( ) -> getAll ( $ page ) ; if ( $ customers instanceof \ Exception ) { throw $ customers ; } foreach ( $ customers as $ customer ) { $ customerObject = new Customer ( $ this -> getCustomerResource ( ) ) ; $ customerObjects [ ] = $ customerObject -> _setAttributes ( $ customer ) ; } return $ customerObjects ; }
|
Get all customers .
|
52,845
|
public function createCustomer ( $ first_name , $ last_name , $ email , $ phone ) { return $ this -> getCustomerModel ( ) -> make ( $ first_name , $ last_name , $ email , $ phone ) -> save ( ) ; }
|
Create new customer .
|
52,846
|
public function getPlans ( $ page = '' ) { $ planObjects = [ ] ; $ plans = $ this -> getPlanResource ( ) -> getAll ( $ page ) ; if ( $ plans instanceof \ Exception ) { throw $ plans ; } foreach ( $ plans as $ plan ) { $ planObject = new Plan ( $ this -> getPlanResource ( ) ) ; $ planObjects [ ] = $ planObject -> _setAttributes ( $ plan ) ; } return $ planObjects ; }
|
Get all plans .
|
52,847
|
public function createPlan ( $ name , $ description , $ amount , $ currency ) { return $ this -> getPlanModel ( ) -> make ( $ name , $ description , $ amount , $ currency ) -> save ( ) ; }
|
Create new plan .
|
52,848
|
public function updatePlan ( $ planCode , $ updateData ) { return $ this -> getPlanModel ( ) -> getPlan ( $ planCode ) -> setUpdateData ( $ updateData ) -> save ( ) ; }
|
Update plan .
|
52,849
|
public function startOneTimeTransaction ( $ amount , $ email , $ plan = '' ) { $ oneTimeTransaction = OneTimeTransaction :: make ( $ amount , $ email , $ plan instanceof Plan ? $ plan -> get ( 'plan_code' ) : $ plan ) ; $ oneTimeTransaction -> setTransactionResource ( $ this -> getTransactionResource ( ) ) ; $ transaction = $ oneTimeTransaction -> initialize ( ) ; if ( $ transaction instanceof \ Exception ) { throw $ transaction ; } return $ transaction ; }
|
Init a one time transaction to get payment page url .
|
52,850
|
public function chargeReturningTransaction ( $ authorization , $ amount , $ email , $ plan = '' ) { $ returningTransaction = ReturningTransaction :: make ( $ authorization , $ amount , $ email , $ plan instanceof Plan ? $ plan -> get ( 'plan_code' ) : $ plan ) ; $ returningTransaction -> setTransactionResource ( $ this -> getTransactionResource ( ) ) ; $ transaction = $ returningTransaction -> charge ( ) ; if ( $ transaction instanceof \ Exception ) { throw $ transaction ; } return $ transaction ; }
|
Charge a returning customer .
|
52,851
|
public function getProviderInfos ( $ handle ) { $ record = $ this -> _getProviderRecordByHandle ( $ handle ) ; if ( $ record ) { return Oauth_ProviderInfosModel :: populateModel ( $ record ) ; } else { $ configProviderInfos = craft ( ) -> config -> get ( 'providerInfos' , 'oauth' ) ; if ( isset ( $ configProviderInfos [ $ handle ] ) ) { $ attributes = [ ] ; if ( isset ( $ configProviderInfos [ $ handle ] [ 'clientId' ] ) ) { $ attributes [ 'clientId' ] = $ configProviderInfos [ $ handle ] [ 'clientId' ] ; } if ( isset ( $ configProviderInfos [ $ handle ] [ 'clientSecret' ] ) ) { $ attributes [ 'clientSecret' ] = $ configProviderInfos [ $ handle ] [ 'clientSecret' ] ; } return Oauth_ProviderInfosModel :: populateModel ( $ attributes ) ; } } }
|
Get provider infos
|
52,852
|
public function getTokenById ( $ id ) { if ( $ id ) { $ record = Oauth_TokenRecord :: model ( ) -> findById ( $ id ) ; if ( $ record ) { $ token = Oauth_TokenModel :: populateModel ( $ record ) ; try { if ( $ this -> _refreshToken ( $ token ) ) { $ this -> saveToken ( $ token ) ; } } catch ( \ Exception $ e ) { OauthPlugin :: log ( "OAuth.Debug - Couldn't refresh token\r\n" . $ e -> getMessage ( ) . '\r\n' . $ e -> getTraceAsString ( ) , LogLevel :: Error , true ) ; } return $ token ; } } }
|
Get token by ID
|
52,853
|
public function deleteToken ( Oauth_TokenModel $ token ) { if ( ! $ token -> id ) { return false ; } $ record = Oauth_TokenRecord :: model ( ) -> findById ( $ token -> id ) ; if ( $ record ) { return $ record -> delete ( ) ; } return false ; }
|
Delete token ID
|
52,854
|
public function deleteTokensByPlugin ( $ pluginHandle ) { $ conditions = 'pluginHandle=:pluginHandle' ; $ params = array ( ':pluginHandle' => $ pluginHandle ) ; return Oauth_TokenRecord :: model ( ) -> deleteAll ( $ conditions , $ params ) ; }
|
Delete tokens by plugin
|
52,855
|
private function _getProviderRecordByHandle ( $ handle ) { $ providerRecord = Oauth_ProviderInfosRecord :: model ( ) -> find ( 'class=:provider' , array ( ':provider' => $ handle ) ) ; if ( $ providerRecord ) { return $ providerRecord ; } return null ; }
|
Get provider record by handle
|
52,856
|
private function _loadProviders ( $ fromRecord = false ) { if ( $ this -> _providersLoaded ) { return ; } $ providerSources = $ this -> _getProviders ( ) ; foreach ( $ providerSources as $ providerSource ) { $ handle = $ providerSource -> getHandle ( ) ; $ record = $ this -> _getProviderRecordByHandle ( $ providerSource -> getHandle ( ) ) ; $ providerInfos = Oauth_ProviderInfosModel :: populateModel ( $ record ) ; $ oauthConfig = craft ( ) -> config -> get ( 'providerInfos' , 'oauth' ) ; if ( $ oauthConfig && ! $ fromRecord ) { if ( ! empty ( $ oauthConfig [ $ providerSource -> getHandle ( ) ] [ 'clientId' ] ) ) { $ providerInfos -> clientId = $ oauthConfig [ $ providerSource -> getHandle ( ) ] [ 'clientId' ] ; } if ( ! empty ( $ oauthConfig [ $ providerSource -> getHandle ( ) ] [ 'clientSecret' ] ) ) { $ providerInfos -> clientSecret = $ oauthConfig [ $ providerSource -> getHandle ( ) ] [ 'clientSecret' ] ; } if ( ! empty ( $ oauthConfig [ $ providerSource -> getHandle ( ) ] [ 'config' ] ) ) { $ providerInfos -> config = $ oauthConfig [ $ providerSource -> getHandle ( ) ] [ 'config' ] ; } } $ providerSource -> setInfos ( $ providerInfos ) ; if ( $ providerSource -> isConfigured ( ) ) { $ this -> _configuredProviders [ $ handle ] = $ providerSource ; } $ this -> _allProviders [ $ handle ] = $ providerSource ; } $ this -> _providersLoaded = true ; }
|
Loads the configured providers .
|
52,857
|
public function initialize ( ) { return ! is_null ( $ this -> transactionRef ) ? $ this -> getTransactionResource ( ) -> initialize ( $ this -> _requestPayload ( ) ) : new PaystackInvalidTransactionException ( json_decode ( json_encode ( [ 'message' => 'Transaction Reference Not Generated.' , ] ) , false ) ) ; }
|
Initialize one time transaction to get payment url .
|
52,858
|
public function verify ( $ transactionRef ) { $ transactionData = $ this -> getTransactionResource ( ) -> verify ( $ transactionRef ) ; if ( $ transactionData instanceof \ Exception ) { throw $ transactionData ; } if ( $ transactionData [ 'status' ] == TransactionContract :: TRANSACTION_STATUS_SUCCESS ) { return [ 'authorization' => $ transactionData [ 'authorization' ] , 'customer' => $ transactionData [ 'customer' ] , 'amount' => $ transactionData [ 'amount' ] , 'plan' => $ transactionData [ 'plan' ] , ] ; } return false ; }
|
Verify Transaction .
|
52,859
|
public function details ( $ transactionId ) { $ transactionData = $ this -> getTransactionResource ( ) -> get ( $ transactionId ) ; if ( $ transactionData instanceof \ Exception ) { throw $ transactionData ; } return TransactionObject :: make ( $ transactionData ) ; }
|
Get transaction details .
|
52,860
|
public function allTransactions ( $ page ) { $ transactions = [ ] ; $ transactionData = $ this -> getTransactionResource ( ) -> getAll ( $ page ) ; if ( $ transactionData instanceof \ Exception ) { throw $ transactionData ; } foreach ( $ transactionData as $ transaction ) { $ transactions [ ] = TransactionObject :: make ( $ transaction ) ; } return $ transactions ; }
|
Get all transactions . per page .
|
52,861
|
protected function fix ( \ DOMNode $ node , $ value ) { $ fixed = $ value ; if ( $ node instanceof \ DOMText ) { $ fixed = str_replace ( "\n" , '' , $ fixed ) ; $ fixed = preg_replace ( '/\s+/u' , ' ' , $ fixed ) ; $ fixed = str_replace ( '<' , '<' , $ fixed ) ; $ fixed = str_replace ( '>' , '>' , $ fixed ) ; } return $ fixed ; }
|
Fix given value based on node type
|
52,862
|
protected function validation ( \ DOMNode $ node , $ value ) { $ boolean = Text :: fullTrim ( $ value ) !== '' && ! in_array ( $ node -> parentNode -> localName , [ 'script' , 'style' , 'noscript' , 'code' ] ) && ! is_numeric ( Text :: fullTrim ( $ value ) ) && ! preg_match ( '/^\d+%$/' , Text :: fullTrim ( $ value ) ) && ! Text :: contains ( Text :: fullTrim ( $ value ) , '[vc_' ) && ! Text :: contains ( Text :: fullTrim ( $ value ) , '<?php' ) ; if ( $ node instanceof \ DOMText ) { $ boolean = $ boolean && strpos ( $ value , Parser :: ATTRIBUTE_NO_TRANSLATE ) === false ; } return $ boolean ; }
|
Some default checks for our value depending on node type
|
52,863
|
protected function replaceCallback ( \ DOMNode $ node ) { return function ( $ text ) use ( $ node ) { $ attribute = '' ; if ( $ node instanceof \ DOMText ) { $ attribute = 'nodeValue' ; } elseif ( $ node instanceof \ DOMAttr ) { $ attribute = 'value' ; } if ( $ attribute === '' ) { throw new ParserCrawlerAfterListenerException ( 'No callback behavior set for this node type.' ) ; } $ text = str_replace ( '&' , '&' , $ text ) ; $ text = str_replace ( '&' , '&' , $ text ) ; $ text = str_replace ( '<' , '<' , $ text ) ; $ text = str_replace ( '>' , '>' , $ text ) ; $ node -> $ attribute = $ text ; } ; }
|
Callback used to replace text with translated version
|
52,864
|
protected function type ( \ DOMNode $ node ) { $ type = null ; if ( $ node instanceof \ DOMText ) { $ type = WordType :: TEXT ; } elseif ( $ node instanceof \ DOMAttr ) { $ type = WordType :: VALUE ; } else { throw new ParserCrawlerAfterListenerException ( 'No word type set for this kind of node.' ) ; } return $ type ; }
|
Get the type of the word given by this kind of node
|
52,865
|
public function loadFromServer ( ) { $ this -> setUrl ( Server :: fullUrl ( $ _SERVER ) ) -> setBot ( Server :: detectBot ( $ _SERVER ) ) ; }
|
Is used to load server data you have to run it manually !
|
52,866
|
public static function unregister ( ) { if ( ! static :: $ protocol ) { return ; } if ( ! stream_wrapper_unregister ( static :: $ protocol ) ) { throw new \ RuntimeException ( sprintf ( 'The protocol "%s" cannot be unregistered from the runtime' , static :: $ protocol ) ) ; } static :: $ protocol = null ; static :: $ pathFactory = null ; static :: $ bufferFactory = null ; }
|
Unregisters the stream wrapper
|
52,867
|
protected function getContextOptions ( $ all = false ) { if ( $ this -> contextOptions === null ) { $ this -> contextOptions = stream_context_get_options ( $ this -> context ) ; } if ( ! $ all && array_key_exists ( self :: $ protocol , $ this -> contextOptions ) ) { return $ this -> contextOptions [ self :: $ protocol ] ; } else if ( $ all ) { return $ this -> contextOptions ; } else { return array ( ) ; } }
|
Parses the passed stream context and returns the context options relevant for this stream wrapper
|
52,868
|
protected function getContextParameters ( ) { if ( $ this -> contextParameters === null ) { $ this -> contextParameters = stream_context_get_params ( $ this -> context ) ; } return $ this -> contextParameters ; }
|
Parses the passed stream context and returns the context parameters
|
52,869
|
protected static function maskHasFlag ( $ mask , $ flag ) { $ flag = ( int ) $ flag ; return ( ( int ) $ mask & $ flag ) === $ flag ; }
|
Checks if a bitmask has a specific flag set
|
52,870
|
public static function open ( $ repositoryPath , $ svn = null ) { $ svn = Binary :: ensure ( $ svn ) ; if ( ! is_string ( $ repositoryPath ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" is not a valid path' , $ repositoryPath ) ) ; } $ repositoryRoot = self :: findRepositoryRoot ( $ svn , $ repositoryPath ) ; if ( $ repositoryRoot === null ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" is not a valid SVN repository' , $ repositoryPath ) ) ; } return new static ( $ repositoryRoot , $ svn ) ; }
|
Opens a SVN repository on the file system
|
52,871
|
public function move ( $ fromPath , $ toPath , $ force = false ) { $ args = array ( ) ; if ( $ force ) { $ args [ ] = '--force' ; } $ args [ ] = $ this -> resolveLocalPath ( $ fromPath ) ; $ args [ ] = $ this -> resolveLocalPath ( $ toPath ) ; $ result = $ this -> getSvn ( ) -> { 'move' } ( $ this -> getRepositoryPath ( ) , $ args ) ; $ result -> assertSuccess ( sprintf ( 'Cannot move "%s" to "%s" in "%s"' , $ fromPath , $ toPath , $ this -> getRepositoryPath ( ) ) ) ; }
|
Renames a file but does not commit the changes
|
52,872
|
public function removeFile ( $ path , $ commitMsg = null , $ recursive = false , $ force = false , $ author = null ) { $ this -> remove ( array ( $ path ) , $ recursive , $ force ) ; if ( $ commitMsg === null ) { $ commitMsg = sprintf ( '%s deleted file "%s"' , __CLASS__ , $ path ) ; } $ this -> commit ( $ commitMsg , array ( $ path ) , $ author ) ; return $ this -> getCurrentCommit ( ) ; }
|
Removes a file and commit the changes immediately
|
52,873
|
public function renameFile ( $ fromPath , $ toPath , $ commitMsg = null , $ force = false , $ author = null ) { $ this -> move ( $ fromPath , $ toPath , $ force ) ; if ( $ commitMsg === null ) { $ commitMsg = sprintf ( '%s renamed/moved file "%s" to "%s"' , __CLASS__ , $ fromPath , $ toPath ) ; } $ this -> commit ( $ commitMsg , array ( $ fromPath , $ toPath ) , $ author ) ; return $ this -> getCurrentCommit ( ) ; }
|
Renames a file and commit the changes immediately
|
52,874
|
public function getStatus ( ) { $ result = $ this -> getSvn ( ) -> { 'status' } ( $ this -> getRepositoryPath ( ) , array ( '--xml' ) ) ; $ result -> assertSuccess ( sprintf ( 'Cannot retrieve status from "%s"' , $ this -> getRepositoryPath ( ) ) ) ; $ xml = simplexml_load_string ( $ result -> getStdOut ( ) ) ; if ( ! $ xml ) { throw new \ RuntimeException ( sprintf ( 'Cannot read status XML for "%s"' , $ this -> getRepositoryPath ( ) ) ) ; } $ status = array ( ) ; foreach ( $ xml -> xpath ( '/status/target/entry' ) as $ entry ) { $ status [ ] = array ( 'file' => ( string ) $ entry [ 'path' ] , 'status' => ( string ) $ entry -> { 'wc-status' } [ 'item' ] ) ; } return $ status ; }
|
Returns the current status of the working directory
|
52,875
|
protected function resolveLocalGlobPath ( array $ files ) { $ absoluteFiles = $ this -> resolveFullPath ( $ files ) ; $ expandedFiles = array ( ) ; foreach ( $ absoluteFiles as $ absoluteFile ) { $ globResult = glob ( $ absoluteFile ) ; if ( empty ( $ globResult ) && stripos ( $ absoluteFile , '*' ) === false && ! file_exists ( $ absoluteFile ) ) { $ expandedFiles [ ] = $ absoluteFile ; } else { $ expandedFiles = array_merge ( $ expandedFiles , $ globResult ) ; } } return $ this -> resolveLocalPath ( $ expandedFiles ) ; }
|
Resolves an absolute path containing glob wildcards into a path relative to the repository path
|
52,876
|
public function setCwd ( $ cwd ) { if ( empty ( $ cwd ) ) { $ cwd = null ; } else { $ cwd = ( string ) $ cwd ; } $ this -> cwd = $ cwd ; return $ this ; }
|
Sets the working directory for the call
|
52,877
|
public function execute ( $ stdIn = null ) { $ stdOut = fopen ( 'php://temp' , 'r' ) ; $ stdErr = fopen ( 'php://temp' , 'r' ) ; $ descriptorSpec = array ( 0 => array ( "pipe" , "r" ) , 1 => $ stdOut , 2 => $ stdErr ) ; $ pipes = array ( ) ; $ process = proc_open ( $ this -> getCmd ( ) , $ descriptorSpec , $ pipes , $ this -> getCwd ( ) , $ this -> getEnv ( ) ) ; if ( is_resource ( $ process ) ) { if ( $ stdIn !== null ) { fwrite ( $ pipes [ 0 ] , ( string ) $ stdIn ) ; } fclose ( $ pipes [ 0 ] ) ; $ returnCode = proc_close ( $ process ) ; return new CallResult ( $ this , $ stdOut , $ stdErr , $ returnCode ) ; } else { fclose ( $ stdOut ) ; fclose ( $ stdErr ) ; throw new \ RuntimeException ( sprintf ( 'Cannot execute "%s"' , $ this -> getCmd ( ) ) ) ; } }
|
Executes the call using the preconfigured command
|
52,878
|
protected function getOptimus ( ) { $ connection = null ; if ( property_exists ( $ this , 'optimusConnection' ) ) { $ connection = $ this -> optimusConnection ; } return app ( 'optimus' ) -> connection ( $ connection ) ; }
|
Get the Optimus instance .
|
52,879
|
private function isConfigured ( ) : bool { if ( ! is_readable ( $ this -> settings [ 'sp_key_file' ] ) ) { return false ; } if ( ! is_readable ( $ this -> settings [ 'sp_cert_file' ] ) ) { return false ; } $ key = file_get_contents ( $ this -> settings [ 'sp_key_file' ] ) ; if ( ! openssl_get_privatekey ( $ key ) ) { return false ; } $ cert = file_get_contents ( $ this -> settings [ 'sp_cert_file' ] ) ; if ( ! openssl_get_publickey ( $ cert ) ) { return false ; } if ( ! SignatureUtils :: certDNEquals ( $ cert , $ this -> settings ) ) { return false ; } return true ; }
|
( i . e . the library has been configured correctly
|
52,880
|
private function configure ( ) { $ keyCert = SignatureUtils :: generateKeyCert ( $ this -> settings ) ; $ dir = dirname ( $ this -> settings [ 'sp_key_file' ] ) ; if ( ! is_dir ( $ dir ) ) { throw new \ InvalidArgumentException ( 'The directory you selected for sp_key_file does not exist. Please create ' . $ dir ) ; } $ dir = dirname ( $ this -> settings [ 'sp_cert_file' ] ) ; if ( ! is_dir ( $ dir ) ) { throw new \ InvalidArgumentException ( 'The directory you selected for sp_cert_file does not exist. Please create ' . $ dir ) ; } file_put_contents ( $ this -> settings [ 'sp_key_file' ] , $ keyCert [ 'key' ] ) ; file_put_contents ( $ this -> settings [ 'sp_cert_file' ] , $ keyCert [ 'cert' ] ) ; }
|
this function should be used with care because it requires write access to the filesystem and invalidates the metadata
|
52,881
|
protected function preConfigure ( Payment $ payment ) { if ( ! $ payment -> getTarget ( ) ) { $ target = new Target ( ) ; $ target -> goid = $ this -> client -> getGoId ( ) ; $ target -> type = TargetType :: ACCOUNT ; $ payment -> setTarget ( $ target ) ; } }
|
Add required target field
|
52,882
|
protected function _camelizePlugin ( $ plugin ) { if ( strpos ( $ plugin , '/' ) === false ) { return Inflector :: camelize ( $ plugin ) ; } list ( $ vendor , $ plugin ) = explode ( '/' , $ plugin , 2 ) ; return Inflector :: camelize ( $ vendor ) . '/' . Inflector :: camelize ( $ plugin ) ; }
|
Camelizes the previously underscored plugin route taking into account plugin vendors
|
52,883
|
protected function _underscore ( $ url ) { foreach ( [ 'controller' , 'plugin' , 'action' ] as $ element ) { if ( ! empty ( $ url [ $ element ] ) ) { $ url [ $ element ] = Inflector :: underscore ( $ url [ $ element ] ) ; } } return $ url ; }
|
Helper method for creating underscore keys in a URL array .
|
52,884
|
public function write ( $ data ) { $ dataLength = strlen ( $ data ) ; $ start = substr ( $ this -> buffer , 0 , $ this -> position ) ; $ end = substr ( $ this -> buffer , $ this -> position + $ dataLength ) ; $ this -> buffer = $ start . $ data . $ end ; $ this -> length = strlen ( $ this -> buffer ) ; $ this -> position += $ dataLength ; return $ dataLength ; }
|
Writes the given date into the buffer at the current pointer position
|
52,885
|
public function setPosition ( $ position , $ whence ) { switch ( $ whence ) { case SEEK_SET : $ this -> position = $ position ; break ; case SEEK_CUR : $ this -> position += $ position ; break ; case SEEK_END : $ this -> position = $ this -> length + $ position ; break ; default : $ this -> position = 0 ; return false ; } if ( $ this -> position < 0 ) { $ this -> position = 0 ; return false ; } else if ( $ this -> position > $ this -> length ) { $ this -> position = $ this -> length ; return false ; } else { return true ; } }
|
Sets the pointer position
|
52,886
|
public function getStat ( ) { $ stat = array ( 'ino' => 0 , 'mode' => ( array_key_exists ( 'mode' , $ this -> objectInfo ) ) ? $ this -> objectInfo [ 'mode' ] : 0 , 'nlink' => 0 , 'uid' => 0 , 'gid' => 0 , 'rdev' => 0 , 'size' => ( array_key_exists ( 'size' , $ this -> objectInfo ) ) ? $ this -> objectInfo [ 'size' ] : 0 , 'atime' => 0 , 'mtime' => 0 , 'ctime' => 0 , 'blksize' => - 1 , 'blocks' => - 1 , ) ; return array_merge ( $ stat , array_values ( $ stat ) ) ; }
|
Returns the stat information for the buffer
|
52,887
|
public function close ( ) { $ this -> buffer = null ; $ this -> length = null ; $ this -> position = null ; $ this -> objectInfo = null ; }
|
Closes the buffer
|
52,888
|
public function addRepositories ( array $ repositories ) { foreach ( $ repositories as $ key => $ repository ) { $ this -> addRepository ( $ key , $ repository ) ; } return $ this ; }
|
Adds multiple repositories
|
52,889
|
public function getRepository ( $ key ) { $ repository = $ this -> tryGetRepository ( $ key ) ; if ( $ repository === null ) { throw new \ OutOfBoundsException ( $ key . ' does not exist in the registry' ) ; } return $ repository ; }
|
Returns the repository if it is registered in the map throws exception otherwise
|
52,890
|
public function getLocalPath ( ) { if ( ! $ this -> localPath ) { $ this -> localPath = $ this -> repository -> resolveLocalPath ( $ this -> fullPath ) ; } return $ this -> localPath ; }
|
Returns the relative path to the resource based on the repository path
|
52,891
|
public function toDatabase ( $ value , Driver $ driver ) { if ( is_array ( $ value ) ) { $ value = $ value [ 'year' ] ; } if ( $ value === null || ! ( int ) $ value ) { return null ; } return $ value ; }
|
Convert binary data into the database format .
|
52,892
|
public function close ( ) { if ( $ this -> stdOut !== null ) { fclose ( $ this -> stdOut ) ; $ this -> stdOut = null ; } if ( $ this -> stdErr !== null ) { fclose ( $ this -> stdErr ) ; $ this -> stdErr = null ; } }
|
Closes the call result and the internal stream resources
|
52,893
|
public static function getDefault ( ) { $ factory = new static ( ) ; $ factory -> addFactory ( new CommitFactory ( ) , 100 ) -> addFactory ( new HeadFileFactory ( ) , 80 ) -> addFactory ( new DefaultFactory ( ) , - 100 ) ; return $ factory ; }
|
Returns a default factory
|
52,894
|
public function addFactory ( FactoryInterface $ factory , $ priority = 10 ) { $ this -> factoryList -> insert ( $ factory , $ priority ) ; return $ this ; }
|
Adds a factory to the list of possible factories
|
52,895
|
public function findFactory ( PathInformationInterface $ path , $ mode ) { $ factoryList = clone $ this -> factoryList ; foreach ( $ factoryList as $ factory ) { if ( $ factory -> canHandle ( $ path , $ mode ) ) { return $ factory ; } } throw new \ RuntimeException ( 'No factory found to handle the requested path' ) ; }
|
Returns the file stream factory to handle the requested path
|
52,896
|
public function canHandle ( PathInformationInterface $ path , $ mode ) { try { $ this -> findFactory ( $ path , $ mode ) ; return true ; } catch ( \ RuntimeException $ e ) { return false ; } }
|
Returns true if this factory can handle the requested path
|
52,897
|
public function make ( array $ config ) : Optimus { $ config = $ this -> getConfig ( $ config ) ; return $ this -> getClient ( $ config ) ; }
|
Make a new Optimus client .
|
52,898
|
protected function compile ( $ stub , $ targetLocation ) { $ view = $ this -> view -> make ( "generator.stubs::$stub" , $ this -> context -> toArray ( ) ) ; $ contents = $ view -> render ( ) ; if ( $ stub != 'composer' ) { $ contents = "<?php\r\n\r\n" . $ contents ; } $ targetDir = base_path ( '/SocialiteProviders/src/' . $ this -> context -> nameStudlyCase ( ) ) ; if ( ! $ this -> files -> isDirectory ( $ targetDir ) ) { $ this -> files -> makeDirectory ( $ targetDir , 0755 , true , true ) ; } $ this -> files -> put ( $ targetDir . '/' . $ targetLocation , $ contents ) ; }
|
Generate the target file from a stub .
|
52,899
|
public function resolveLocalPath ( $ path ) { if ( is_array ( $ path ) ) { $ paths = array ( ) ; foreach ( $ path as $ p ) { $ paths [ ] = $ this -> resolveLocalPath ( $ p ) ; } return $ paths ; } else { $ path = FileSystem :: normalizeDirectorySeparator ( $ path ) ; if ( strpos ( $ path , $ this -> getRepositoryPath ( ) ) === 0 ) { $ path = substr ( $ path , strlen ( $ this -> getRepositoryPath ( ) ) ) ; } return ltrim ( $ path , '/' ) ; } }
|
Resolves an absolute path into a path relative to the repository path
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.