idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
44,600
public function verifyIPN ( $ post ) { $ this -> setRequestData ( $ post ) ; $ this -> apiUrl = $ this -> config [ 'ipn_url' ] ; return $ this -> doPayPalRequest ( 'verifyipn' ) ; }
Retrieve PayPal IPN Response .
44,601
public function doReferenceTransaction ( $ transaction , $ action , $ amount = 0.00 ) { $ this -> setRequestData ( [ 'REFERENCEID' => $ transaction , 'PAYMENTACTION' => $ action , 'AMT' => $ amount , ] ) ; return $ this -> doPayPalRequest ( 'DoReferenceTransaction' ) ; }
Perform a DoReferenceTransaction API operation on PayPal .
44,602
public function refundTransaction ( $ transaction , $ amount = 0.00 ) { $ this -> setRequestData ( [ 'TRANSACTIONID' => $ transaction , ] ) ; if ( $ amount > 0 ) { $ this -> post = $ this -> post -> merge ( [ 'REFUNDTYPE' => 'Partial' , 'AMT' => $ amount , ] ) ; } return $ this -> doPayPalRequest ( 'RefundTransaction' ...
Refund PayPal Transaction .
44,603
public function setExpressCheckoutOptions ( $ credentials ) { if ( $ this -> mode === 'sandbox' ) { $ this -> config [ 'api_url' ] = ! empty ( $ this -> config [ 'secret' ] ) ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api.sandbox.paypal.com/nvp' ; $ this -> config [ 'gateway_url' ] = 'https://www.sandbox.payp...
Set ExpressCheckout API endpoints & options .
44,604
protected function setCartItems ( $ items ) { return ( new Collection ( $ items ) ) -> map ( function ( $ item , $ num ) { return [ 'L_PAYMENTREQUEST_0_NAME' . $ num => $ item [ 'name' ] , 'L_PAYMENTREQUEST_0_AMT' . $ num => $ item [ 'price' ] , 'L_PAYMENTREQUEST_0_QTY' . $ num => isset ( $ item [ 'qty' ] ) ? $ item [ ...
Set cart item details for PayPal .
44,605
protected function setExpressCheckoutRecurringPaymentConfig ( $ data , $ subscription = false ) { $ billingType = $ this -> billingType ; if ( $ subscription ) { $ billingType = 'RecurringPayments' ; } if ( isset ( $ billingType ) ) { $ this -> post = $ this -> post -> merge ( [ 'L_BILLINGTYPE0' => $ billingType , 'L_B...
Set Recurring payments details for SetExpressCheckout API call .
44,606
protected function setShippingAmount ( $ data ) { if ( isset ( $ data [ 'shipping' ] ) ) { $ this -> post = $ this -> post -> merge ( [ 'PAYMENTREQUEST_0_SHIPPINGAMT' => $ data [ 'shipping' ] , ] ) ; } }
Set shipping amount if available .
44,607
protected function setShippingDiscount ( $ data ) { if ( isset ( $ data [ 'shipping_discount' ] ) ) { if ( $ data [ 'shipping_discount' ] > 0 ) { $ data [ 'shipping_discount' ] *= - 1 ; } $ this -> post = $ this -> post -> merge ( [ 'PAYMENTREQUEST_0_SHIPDISCAMT' => $ data [ 'shipping_discount' ] , 'PAYMENTREQUEST_0_AM...
Set shipping discount if available .
44,608
public function setExpressCheckout ( $ data , $ subscription = false ) { $ this -> setItemSubTotal ( $ data ) ; $ this -> post = $ this -> setCartItems ( $ data [ 'items' ] ) -> merge ( [ 'PAYMENTREQUEST_0_ITEMAMT' => $ this -> subtotal , 'PAYMENTREQUEST_0_AMT' => $ data [ 'total' ] , 'PAYMENTREQUEST_0_PAYMENTACTION' =...
Perform a SetExpressCheckout API call on PayPal .
44,609
public function doExpressCheckoutPayment ( $ data , $ token , $ payerid ) { $ this -> setItemSubTotal ( $ data ) ; $ this -> post = $ this -> setCartItems ( $ data [ 'items' ] ) -> merge ( [ 'TOKEN' => $ token , 'PAYERID' => $ payerid , 'PAYMENTREQUEST_0_ITEMAMT' => $ this -> subtotal , 'PAYMENTREQUEST_0_AMT' => $ data...
Perform DoExpressCheckoutPayment API call on PayPal .
44,610
public function doAuthorization ( $ authorization_id , $ amount , $ data = [ ] ) { $ this -> setRequestData ( array_merge ( $ data , [ 'AUTHORIZATIONID' => $ authorization_id , 'AMT' => $ amount , ] ) ) ; return $ this -> doPayPalRequest ( 'DoAuthorization' ) ; }
Perform a DoAuthorization API call on PayPal .
44,611
public function doCapture ( $ authorization_id , $ amount , $ complete = 'Complete' , $ data = [ ] ) { $ this -> setRequestData ( array_merge ( $ data , [ 'AUTHORIZATIONID' => $ authorization_id , 'AMT' => $ amount , 'COMPLETETYPE' => $ complete , 'CURRENCYCODE' => $ this -> currency , ] ) ) ; return $ this -> doPayPal...
Perform a DoCapture API call on PayPal .
44,612
public function doReAuthorization ( $ authorization_id , $ amount , $ data = [ ] ) { $ this -> setRequestData ( array_merge ( $ data , [ 'AUTHORIZATIONID' => $ authorization_id , 'AMOUNT' => $ amount , ] ) ) ; return $ this -> doPayPalRequest ( 'DoReauthorization' ) ; }
Perform a DoReauthorization API call on PayPal to reauthorize an existing authorization transaction .
44,613
public function doVoid ( $ authorization_id , $ data = [ ] ) { $ this -> setRequestData ( array_merge ( $ data , [ 'AUTHORIZATIONID' => $ authorization_id , ] ) ) ; return $ this -> doPayPalRequest ( 'DoVoid' ) ; }
Perform a DoVoid API call on PayPal .
44,614
public function createRecurringPaymentsProfile ( $ data , $ token ) { $ this -> post = $ this -> setRequestData ( $ data ) -> merge ( [ 'TOKEN' => $ token , ] ) ; return $ this -> doPayPalRequest ( 'CreateRecurringPaymentsProfile' ) ; }
Perform a CreateRecurringPaymentsProfile API call on PayPal .
44,615
public function updateRecurringPaymentsProfile ( $ data , $ id ) { $ this -> post = $ this -> setRequestData ( $ data ) -> merge ( [ 'PROFILEID' => $ id , ] ) ; return $ this -> doPayPalRequest ( 'UpdateRecurringPaymentsProfile' ) ; }
Perform a UpdateRecurringPaymentsProfile API call on PayPal .
44,616
public static function setProvider ( $ option = '' ) { if ( empty ( $ option ) || ( $ option != 'adaptive_payments' ) || ( $ option == 'express_checkout' ) ) { self :: $ provider = new ExpressCheckout ( ) ; } else { self :: $ provider = new AdaptivePayments ( ) ; } return self :: getProvider ( ) ; }
Set specific PayPal API to use .
44,617
public function setAdaptivePaymentsOptions ( ) { if ( $ this -> mode == 'sandbox' ) { $ this -> config [ 'api_url' ] = 'https://svcs.sandbox.paypal.com/AdaptivePayments' ; $ this -> config [ 'gateway_url' ] = 'https://www.sandbox.paypal.com/cgi-bin/webscr' ; } else { $ this -> config [ 'api_url' ] = 'https://svcs.paypa...
Set AdaptivePayments API endpoints & options .
44,618
private function setHeaders ( ) { $ headers = [ 'X-PAYPAL-SECURITY-USERID' => $ this -> config [ 'username' ] , 'X-PAYPAL-SECURITY-PASSWORD' => $ this -> config [ 'password' ] , 'X-PAYPAL-SECURITY-SIGNATURE' => $ this -> config [ 'signature' ] , 'X-PAYPAL-REQUEST-DATA-FORMAT' => 'JSON' , 'X-PAYPAL-RESPONSE-DATA-FORMAT'...
Set Adaptive Payments API request headers .
44,619
private function setPayRequestDetails ( $ data ) { $ this -> post = $ this -> setRequestData ( [ 'actionType' => 'PAY' , 'currencyCode' => $ this -> currency , 'receiverList' => [ 'receiver' => $ data [ 'receivers' ] , ] , 'returnUrl' => $ data [ 'return_url' ] , 'cancelUrl' => $ data [ 'cancel_url' ] , 'requestEnvelop...
Set request details for Pay API operation .
44,620
public function createPayRequest ( $ data ) { if ( empty ( $ data [ 'return_url' ] ) && empty ( $ data [ 'cancel_url' ] ) ) { throw new \ Exception ( 'Return & Cancel URL should be specified' ) ; } $ this -> setPayRequestDetails ( $ data ) ; return $ this -> doPayPalRequest ( 'Pay' ) ; }
Function to perform Adaptive Payments API s PAY operation .
44,621
public function setPaymentOptions ( $ payKey , $ receivers ) { $ this -> post = $ this -> setRequestData ( [ 'requestEnvelope' => $ this -> setEnvelope ( ) , 'payKey' => $ payKey , ] ) -> merge ( [ 'receiverOptions' => $ this -> setPaymentOptionsReceiverDetails ( $ receivers ) , ] ) ; return $ this -> doPayPalRequest (...
Function to perform Adaptive Payments API s SetPaymentOptions operation .
44,622
public function getPaymentOptions ( $ payKey , $ details = false ) { $ operation = ( $ details ) ? 'PaymentDetails' : 'GetPaymentOptions' ; $ this -> setRequestData ( [ 'requestEnvelope' => $ this -> setEnvelope ( ) , 'payKey' => $ payKey , ] ) ; return $ this -> doPayPalRequest ( $ operation ) ; }
Function to perform Adaptive Payments API s GetPaymentOptions operation .
44,623
public function getRedirectUrl ( $ option , $ payKey ) { $ url = $ this -> config [ 'gateway_url' ] . '?cmd=' ; if ( $ option == 'approved' ) { $ url .= '_ap-payment&paykey=' . $ payKey ; } elseif ( $ option == 'pre-approved' ) { $ url .= '_ap-preapproval&preapprovalkey=' . $ payKey ; } return $ url ; }
Get PayPal redirect url for processing payment .
44,624
private function setPaymentOptionsReceiverDetails ( $ receivers ) { return collect ( $ receivers ) -> map ( function ( $ receiver ) { $ item = [ ] ; $ item [ 'receiver' ] = [ 'email' => $ receiver [ 'email' ] , ] ; $ item [ 'invoiceData' ] [ 'item' ] = collect ( $ receiver [ 'invoice_data' ] ) -> map ( function ( $ inv...
Set receiver details for SetPaymentOptions .
44,625
protected function setHttpClientConfiguration ( ) { $ this -> setCurlConstants ( ) ; $ this -> httpClientConfig = [ CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2 , CURLOPT_SSL_VERIFYPEER => $ this -> validateSSL , ] ; if ( ! empty ( $ this -> certificate ) ) { $ this -> httpClientConfig [ CURLOPT_SSLCERT ] = $ this -> ...
Function to set Http Client configuration .
44,626
public function execute ( $ server , $ frame ) { $ skip = false ; foreach ( $ this -> strategies as $ strategy ) { $ result = App :: invokeMethod ( [ $ strategy , 'handle' ] , [ 'server' => $ server , 'frame' => $ frame , ] ) ; if ( $ result === true ) { $ skip = true ; break ; } } return $ skip ; }
Execute strategies before decoding payload . If return value is true will skip decoding .
44,627
public function emit ( string $ event , $ data ) : bool { $ fds = $ this -> getFds ( ) ; $ assigned = ! empty ( $ this -> to ) ; if ( empty ( $ fds ) && $ assigned ) { return false ; } $ result = $ this -> app -> make ( Server :: class ) -> task ( [ 'action' => static :: PUSH_ACTION , 'data' => [ 'sender' => $ this -> ...
Emit data and reset some status .
44,628
protected function checkTable ( string $ table ) { if ( ! in_array ( $ table , [ RoomContract :: ROOMS_KEY , RoomContract :: DESCRIPTORS_KEY ] ) ) { throw new InvalidArgumentException ( "Invalid table name: `{$table}`." ) ; } }
Check table for rooms and descriptors .
44,629
public function onMessage ( $ server , $ frame ) { if ( $ this -> payloadParser -> execute ( $ server , $ frame ) ) { return ; } $ websocket = $ this -> app -> make ( Websocket :: class ) ; $ sandbox = $ this -> app -> make ( Sandbox :: class ) ; try { $ payload = $ this -> payloadParser -> decode ( $ frame ) ; $ webso...
onMessage listener .
44,630
public function onClose ( $ server , $ fd , $ reactorId ) { if ( ! $ this -> isServerWebsocket ( $ fd ) || ! $ server instanceof Server ) { return ; } $ websocket = $ this -> app -> make ( Websocket :: class ) ; try { $ websocket -> reset ( true ) -> setSender ( $ fd ) ; if ( $ websocket -> eventExists ( 'disconnect' )...
onClose listener .
44,631
protected function registerTables ( ) { $ tables = $ this -> container -> make ( 'config' ) -> get ( 'swoole.tables' , [ ] ) ; foreach ( $ tables as $ key => $ value ) { $ table = new SwooleTable ( $ value [ 'size' ] ) ; $ columns = $ value [ 'columns' ] ?? [ ] ; foreach ( $ columns as $ column ) { if ( isset ( $ colum...
Register user - defined swoole tables .
44,632
protected function setSwooleServerListeners ( ) { foreach ( $ this -> events as $ event ) { $ listener = Str :: camel ( "on_$event" ) ; $ callback = method_exists ( $ this , $ listener ) ? [ $ this , $ listener ] : function ( ) use ( $ event ) { $ this -> container -> event -> trigger ( "swoole.$event" , func_get_args ...
Set swoole server listeners .
44,633
public function build ( $ collection , array $ fields , $ config = [ ] ) { $ this -> config = $ config ; $ csv = $ this -> writer ; $ headers = [ ] ; foreach ( $ fields as $ key => $ field ) { $ headers [ ] = $ field ; if ( ! is_numeric ( $ key ) ) { $ fields [ $ key ] = $ key ; } } if ( is_a ( $ collection , EloquentC...
Build the writer .
44,634
public function download ( $ filename = null ) { $ filename = $ filename ? : date ( 'Y-m-d_His' ) . '.csv' ; $ this -> writer -> output ( $ filename ) ; }
Download the CSV file .
44,635
private function addCsvRows ( Collection $ collection , array $ fields , Writer $ csv ) { if ( $ this -> isEloquentCollection ) { $ collection -> makeVisible ( $ fields ) ; } foreach ( $ collection as $ model ) { $ beforeEachCallback = $ this -> beforeEachCallback ; if ( $ beforeEachCallback ) { $ return = $ beforeEach...
Add rows to the CSV .
44,636
public function fileDetails ( $ path ) { $ path = '/' . ltrim ( $ path , '/' ) ; return [ 'name' => basename ( $ path ) , 'fullPath' => $ path , 'webPath' => $ this -> fileWebPath ( $ path ) , 'mimeType' => $ this -> fileMimeType ( $ path ) , 'size' => $ this -> fileSize ( $ path ) , ] ; }
Return an array of file details for a file .
44,637
public function getLoginUrl ( $ scopes = array ( 'basic' ) ) { if ( is_array ( $ scopes ) && count ( array_intersect ( $ scopes , $ this -> _scopes ) ) === count ( $ scopes ) ) { return self :: API_OAUTH_URL . '?client_id=' . $ this -> getApiKey ( ) . '&redirect_uri=' . urlencode ( $ this -> getApiCallback ( ) ) . '&sc...
Generates the OAuth login URL .
44,638
public function searchUser ( $ name , $ limit = 0 ) { $ params = array ( ) ; $ params [ 'q' ] = $ name ; if ( $ limit > 0 ) { $ params [ 'count' ] = $ limit ; } return $ this -> _makeCall ( 'users/search' , false , $ params ) ; }
Search for a user .
44,639
public function getUser ( $ id = 0 ) { $ auth = false ; if ( $ id === 0 && isset ( $ this -> _accesstoken ) ) { $ id = 'self' ; $ auth = true ; } return $ this -> _makeCall ( 'users/' . $ id , $ auth ) ; }
Get user info .
44,640
public function getUserFeed ( $ limit = 0 ) { $ params = array ( ) ; if ( $ limit > 0 ) { $ params [ 'count' ] = $ limit ; } return $ this -> _makeCall ( 'users/self/feed' , true , $ params ) ; }
Get user activity feed .
44,641
public function getUserMedia ( $ id = 'self' , $ limit = 0 ) { $ params = array ( ) ; if ( $ limit > 0 ) { $ params [ 'count' ] = $ limit ; } return $ this -> _makeCall ( 'users/' . $ id . '/media/recent' , strlen ( $ this -> getAccessToken ( ) ) , $ params ) ; }
Get user recent media .
44,642
public function getUserLikes ( $ limit = 0 ) { $ params = array ( ) ; if ( $ limit > 0 ) { $ params [ 'count' ] = $ limit ; } return $ this -> _makeCall ( 'users/self/media/liked' , true , $ params ) ; }
Get the liked photos of a user .
44,643
public function getUserFollows ( $ id = 'self' , $ limit = 0 ) { $ params = array ( ) ; if ( $ limit > 0 ) { $ params [ 'count' ] = $ limit ; } return $ this -> _makeCall ( 'users/' . $ id . '/follows' , true , $ params ) ; }
Get the list of users this user follows
44,644
public function getUserFollower ( $ id = 'self' , $ limit = 0 ) { $ params = array ( ) ; if ( $ limit > 0 ) { $ params [ 'count' ] = $ limit ; } return $ this -> _makeCall ( 'users/' . $ id . '/followed-by' , true , $ params ) ; }
Get the list of users this user is followed by .
44,645
public function searchMedia ( $ lat , $ lng , $ distance = 1000 , $ minTimestamp = null , $ maxTimestamp = null ) { return $ this -> _makeCall ( 'media/search' , false , array ( 'lat' => $ lat , 'lng' => $ lng , 'distance' => $ distance , 'min_timestamp' => $ minTimestamp , 'max_timestamp' => $ maxTimestamp ) ) ; }
Search media by its location .
44,646
public function getTagMedia ( $ name , $ limit = 0 ) { $ params = array ( ) ; if ( $ limit > 0 ) { $ params [ 'count' ] = $ limit ; } return $ this -> _makeCall ( 'tags/' . $ name . '/media/recent' , false , $ params ) ; }
Get a recently tagged media .
44,647
public function searchLocation ( $ lat , $ lng , $ distance = 1000 ) { return $ this -> _makeCall ( 'locations/search' , false , array ( 'lat' => $ lat , 'lng' => $ lng , 'distance' => $ distance ) ) ; }
Get recent media from a given location .
44,648
public function pagination ( $ obj , $ limit = 0 ) { if ( is_object ( $ obj ) && ! is_null ( $ obj -> pagination ) ) { if ( ! isset ( $ obj -> pagination -> next_url ) ) { return ; } $ apiCall = explode ( '?' , $ obj -> pagination -> next_url ) ; if ( count ( $ apiCall ) < 2 ) { return ; } $ function = str_replace ( se...
Pagination feature .
44,649
public function getOAuthToken ( $ code , $ token = false ) { $ apiData = array ( 'grant_type' => 'authorization_code' , 'client_id' => $ this -> getApiKey ( ) , 'client_secret' => $ this -> getApiSecret ( ) , 'redirect_uri' => $ this -> getApiCallback ( ) , 'code' => $ code ) ; $ result = $ this -> _makeOAuthCall ( $ a...
Get the OAuth data of a user by the returned callback code .
44,650
protected function _makeCall ( $ function , $ auth = false , $ params = null , $ method = 'GET' ) { if ( ! $ auth ) { $ authMethod = '?client_id=' . $ this -> getApiKey ( ) ; } else { if ( ! isset ( $ this -> _accesstoken ) ) { throw new InstagramException ( "Error: _makeCall() | $function - This method requires an aut...
The call operator .
44,651
private function _makeOAuthCall ( $ apiData ) { $ apiHost = self :: API_OAUTH_TOKEN_URL ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ apiHost ) ; curl_setopt ( $ ch , CURLOPT_POST , count ( $ apiData ) ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , http_build_query ( $ apiData ) ) ; curl_setopt ( $ ch , ...
The OAuth call operator .
44,652
private function _signHeader ( $ endpoint , $ authMethod , $ params ) { if ( ! is_array ( $ params ) ) { $ params = array ( ) ; } if ( $ authMethod ) { list ( $ key , $ value ) = explode ( '=' , substr ( $ authMethod , 1 ) , 2 ) ; $ params [ $ key ] = $ value ; } $ baseString = '/' . $ endpoint ; ksort ( $ params ) ; f...
Sign header by using endpoint parameters and the API secret .
44,653
private function processHeaders ( $ headerContent ) { $ headers = array ( ) ; foreach ( explode ( "\r\n" , $ headerContent ) as $ i => $ line ) { if ( $ i === 0 ) { $ headers [ 'http_code' ] = $ line ; continue ; } list ( $ key , $ value ) = explode ( ':' , $ line ) ; $ headers [ $ key ] = $ value ; } return $ headers ...
Read and process response header content .
44,654
protected function enablePhpMarkdownEngine ( ) { $ app = $ this -> app ; $ app -> view -> getEngineResolver ( ) -> register ( 'phpmd' , function ( ) use ( $ app ) { $ markdown = $ app [ 'markdown' ] ; return new PhpMarkdownEngine ( $ markdown ) ; } ) ; $ app -> view -> addExtension ( 'md.php' , 'phpmd' ) ; }
Enable the php markdown engine .
44,655
protected function enableBladeMarkdownEngine ( ) { $ app = $ this -> app ; $ app -> view -> getEngineResolver ( ) -> register ( 'blademd' , function ( ) use ( $ app ) { $ compiler = $ app [ 'blade.compiler' ] ; $ markdown = $ app [ 'markdown' ] ; return new BladeMarkdownEngine ( $ compiler , $ markdown ) ; } ) ; $ app ...
Enable the blade markdown engine .
44,656
protected function registerEnvironment ( ) { $ this -> app -> singleton ( 'markdown.environment' , function ( Container $ app ) { $ environment = Environment :: createCommonMarkEnvironment ( ) ; $ config = $ app -> config -> get ( 'markdown' ) ; $ environment -> mergeConfig ( array_except ( $ config , [ 'extensions' , ...
Register the environment class .
44,657
protected function registerMarkdown ( ) { $ this -> app -> singleton ( 'markdown' , function ( Container $ app ) { $ environment = $ app [ 'markdown.environment' ] ; $ docParser = new DocParser ( $ environment ) ; $ htmlRenderer = new HtmlRenderer ( $ environment ) ; return new Converter ( $ docParser , $ htmlRenderer ...
Register the markdowm class .
44,658
protected function registerCompiler ( ) { $ this -> app -> singleton ( 'markdown.compiler' , function ( Container $ app ) { $ markdown = $ app [ 'markdown' ] ; $ files = $ app [ 'files' ] ; $ storagePath = $ app -> config -> get ( 'view.compiled' ) ; return new MarkdownCompiler ( $ markdown , $ files , $ storagePath ) ...
Register the markdown compiler class .
44,659
public function new ( ) { if ( isset ( $ this -> constructor ) ) { $ constructor = $ this -> constructor ; $ arguments = func_get_args ( ) ; $ callback = array_pop ( $ arguments ) ; $ input_count = isset ( $ constructor [ 'inputs' ] ) ? count ( $ constructor [ 'inputs' ] ) : 0 ; if ( count ( $ arguments ) < $ input_cou...
new Deploy a contruct with params .
44,660
public function getData ( ) { if ( isset ( $ this -> functions ) || isset ( $ this -> constructor ) ) { $ arguments = func_get_args ( ) ; $ functionData = '' ; if ( empty ( $ this -> toAddress ) && ! empty ( $ this -> bytecode ) ) { $ constructor = $ this -> constructor ; if ( count ( $ arguments ) < count ( $ construc...
getData Get the function method call data . With this function you can send signed contract function transaction . 1 . Get the funtion data with params . 2 . Sign the data with user private key . 3 . Call sendRawTransaction .
44,661
private function config_path ( $ path = '' ) { return function_exists ( 'config_path' ) ? config_path ( $ path ) : app ( ) -> basePath ( ) . DIRECTORY_SEPARATOR . 'config' . ( $ path ? DIRECTORY_SEPARATOR . $ path : $ path ) ; }
Get the configuration path .
44,662
public function actionSwitch ( $ id = null ) { if ( ! $ this -> module -> enableImpersonateUser ) { throw new ForbiddenHttpException ( Yii :: t ( 'user' , 'Impersonate user is disabled in the application configuration' ) ) ; } if ( ! $ id && Yii :: $ app -> session -> has ( self :: ORIGINAL_USER_SESSION_KEY ) ) { $ use...
Switches to the given user for the rest of the Session . When no id is given we switch back to the original admin user that started the impersonation .
44,663
public function sendGeneratedPassword ( User $ user , $ password ) { return $ this -> sendMessage ( $ user -> email , $ this -> getNewPasswordSubject ( ) , 'new_password' , [ 'user' => $ user , 'password' => $ password , 'module' => $ this -> module ] ) ; }
Sends a new generated password to a user .
44,664
public function getAccountByProvider ( $ provider ) { $ accounts = $ this -> getAccounts ( ) ; return isset ( $ accounts [ $ provider ] ) ? $ accounts [ $ provider ] : null ; }
Returns connected account by provider .
44,665
public function attemptEmailChange ( $ code ) { $ token = $ this -> finder -> findToken ( [ 'user_id' => $ this -> id , 'code' => $ code , ] ) -> andWhere ( [ 'in' , 'type' , [ Token :: TYPE_CONFIRM_NEW_EMAIL , Token :: TYPE_CONFIRM_OLD_EMAIL ] ] ) -> one ( ) ; if ( empty ( $ this -> unconfirmed_email ) || $ token === ...
This method attempts changing user email . If user s unconfirmed_email field is empty is returns false else if somebody already has email that equals user s unconfirmed_email it returns false otherwise returns true and updates user s password .
44,666
public function confirm ( ) { $ this -> trigger ( self :: BEFORE_CONFIRM ) ; $ result = ( bool ) $ this -> updateAttributes ( [ 'confirmed_at' => time ( ) ] ) ; $ this -> trigger ( self :: AFTER_CONFIRM ) ; return $ result ; }
Confirms the user by setting confirmed_at field to current time .
44,667
public function generateUsername ( ) { $ username = explode ( '@' , $ this -> email ) [ 0 ] ; $ this -> username = $ username ; if ( $ this -> validate ( [ 'username' ] ) ) { return $ this -> username ; } if ( ! preg_match ( self :: $ usernameRegexp , $ username ) ) { $ username = 'user' ; } $ this -> username = $ user...
Generates new username based on email address or creates new username like emailuser1 .
44,668
public function isConnected ( ClientInterface $ provider ) { return $ this -> accounts != null && isset ( $ this -> accounts [ $ provider -> getId ( ) ] ) ; }
Checks if provider already connected to user .
44,669
public static function loginList ( ) { $ module = \ Yii :: $ app -> getModule ( 'user' ) ; $ userModel = $ module -> modelMap [ 'User' ] ; return ArrayHelper :: map ( $ userModel :: find ( ) -> where ( [ 'blocked_at' => null ] ) -> all ( ) , 'username' , function ( $ user ) { return sprintf ( '%s (%s)' , Html :: encode...
Gets all users to generate the dropdown list when in debug mode .
44,670
public function validatePassword ( $ attribute , $ params ) { if ( $ this -> user === null || ! Password :: validate ( $ this -> password , $ this -> user -> password_hash ) ) $ this -> addError ( $ attribute , Yii :: t ( 'user' , 'Invalid login or password' ) ) ; }
Validates if the hash of the given password is identical to the saved hash in the database . It will always succeed if the module is in DEBUG mode .
44,671
public function actionDelete ( ) { if ( ! $ this -> module -> enableAccountDelete ) { throw new NotFoundHttpException ( \ Yii :: t ( 'user' , 'Not found' ) ) ; } $ user = \ Yii :: $ app -> user -> identity ; $ event = $ this -> getUserEvent ( $ user ) ; \ Yii :: $ app -> user -> logout ( ) ; $ this -> trigger ( self ::...
Completely deletes user s account .
44,672
public function findTokenByParams ( $ userId , $ code , $ type ) { return $ this -> findToken ( [ 'user_id' => $ userId , 'code' => $ code , 'type' => $ type , ] ) -> one ( ) ; }
Finds a token by params .
44,673
public function toLocalTime ( \ DateTime $ dateTime = null ) { if ( $ dateTime === null ) { $ dateTime = new \ DateTime ( ) ; } return $ dateTime -> setTimezone ( $ this -> getTimeZone ( ) ) ; }
Converts DateTime to user s local time
44,674
public function ensureCorrectDebugSetting ( ) { if ( ! defined ( 'YII_DEBUG' ) ) { return false ; } if ( ! defined ( 'YII_ENV' ) ) { return false ; } if ( defined ( 'YII_ENV' ) && YII_ENV !== 'dev' ) { return false ; } if ( defined ( 'YII_DEBUG' ) && YII_DEBUG !== true ) { return false ; } return Yii :: $ app -> getMod...
Ensure the module is not in DEBUG mode on production environments
44,675
public function getConnectUrl ( ) { $ code = \ Yii :: $ app -> security -> generateRandomString ( ) ; $ this -> updateAttributes ( [ 'code' => md5 ( $ code ) ] ) ; return Url :: to ( [ '/user/registration/connect' , 'code' => $ code ] ) ; }
Returns connect url .
44,676
public function make ( $ pathToFile , $ type = 'zip' ) { $ new = $ this -> createArchiveFile ( $ pathToFile ) ; $ objectOrName = $ type ; if ( is_string ( $ type ) ) { $ objectOrName = 'Chumper\Zipper\Repositories\\' . ucwords ( $ type ) . 'Repository' ; } if ( ! is_subclass_of ( $ objectOrName , 'Chumper\Zipper\Reposi...
Create a new zip Archive if the file does not exists opens a zip archive if the file exists
44,677
public function getFileContent ( $ filePath ) { if ( $ this -> repository -> fileExists ( $ filePath ) === false ) { throw new Exception ( sprintf ( 'The file "%s" cannot be found' , $ filePath ) ) ; } return $ this -> repository -> getFileContent ( $ filePath ) ; }
Gets the content of a single file if available
44,678
public function add ( $ pathToAdd , $ fileName = null ) { if ( is_array ( $ pathToAdd ) ) { foreach ( $ pathToAdd as $ key => $ dir ) { if ( ! is_int ( $ key ) ) { $ this -> add ( $ dir , $ key ) ; } else { $ this -> add ( $ dir ) ; } } } elseif ( $ this -> file -> isFile ( $ pathToAdd ) ) { if ( $ fileName ) { $ this ...
Add one or multiple files to the zip .
44,679
public function remove ( $ fileToRemove ) { if ( is_array ( $ fileToRemove ) ) { $ self = $ this ; $ this -> repository -> each ( function ( $ file ) use ( $ fileToRemove , $ self ) { if ( starts_with ( $ file , $ fileToRemove ) ) { $ self -> getRepository ( ) -> removeFile ( $ file ) ; } } ) ; } else { $ this -> repos...
Remove a file or array of files and folders from the zip archive
44,680
public function delete ( ) { if ( null !== $ this -> repository ) { $ this -> repository -> close ( ) ; } $ this -> file -> delete ( $ this -> filePath ) ; $ this -> filePath = '' ; }
Deletes the archive file
44,681
public function listFiles ( $ regexFilter = null ) { $ filesList = [ ] ; if ( $ regexFilter ) { $ filter = function ( $ file ) use ( & $ filesList , $ regexFilter ) { set_error_handler ( function ( ) { } ) ; $ match = preg_match ( $ regexFilter , $ file ) ; restore_error_handler ( ) ; if ( $ match === 1 ) { $ filesList...
List all files that are within the archive
44,682
private function addFile ( $ pathToAdd , $ fileName = null ) { if ( ! $ fileName ) { $ info = pathinfo ( $ pathToAdd ) ; $ fileName = isset ( $ info [ 'extension' ] ) ? $ info [ 'filename' ] . '.' . $ info [ 'extension' ] : $ info [ 'filename' ] ; } $ this -> repository -> addFile ( $ pathToAdd , $ this -> getInternalP...
Add the file to the zip
44,683
private function addFromString ( $ filename , $ content ) { $ this -> repository -> addFromString ( $ this -> getInternalPath ( ) . $ filename , $ content ) ; }
Add the file to the zip from content
44,684
public function each ( $ callback ) { for ( $ i = 0 ; $ i < $ this -> archive -> numFiles ; ++ $ i ) { $ stats = $ this -> archive -> statIndex ( $ i ) ; if ( $ stats [ 'size' ] === 0 && $ stats [ 'crc' ] === 0 ) { continue ; } call_user_func_array ( $ callback , [ 'file' => $ this -> archive -> getNameIndex ( $ i ) , ...
Will loop over every item in the archive and will execute the callback on them Will provide the filename for every item
44,685
private function normalizeExpiry ( int $ expiry ) : int { if ( $ expiry > self :: THIRTY_DAYS_IN_SECONDS ) { return time ( ) + $ expiry ; } return $ expiry ; }
Expiry treated as a unix timestamp instead of an offset if expiry is greater than 30 days .
44,686
private function findById ( $ id , bool $ includeData = true ) : ? array { [ $ idField ] = $ fields = $ this -> getFields ( ) ; if ( ! $ includeData ) { $ key = array_search ( static :: DATA_FIELD , $ fields ) ; unset ( $ fields [ $ key ] ) ; } $ statement = $ this -> sqlite -> prepare ( sprintf ( 'SELECT %s FROM %s WH...
Find a single row by ID .
44,687
private function isExpired ( array $ item ) : bool { return isset ( $ item [ static :: EXPIRATION_FIELD ] ) && $ item [ self :: EXPIRATION_FIELD ] !== null && $ item [ self :: EXPIRATION_FIELD ] < time ( ) ; }
Check if the item is expired .
44,688
private function isExpired ( RiakObject $ object ) : bool { $ metadataMap = $ object -> getMetadataMap ( ) ; return isset ( $ metadataMap [ self :: EXPIRES_HEADER ] ) && $ metadataMap [ self :: EXPIRES_HEADER ] < time ( ) ; }
Check if a given RiakObject has expired .
44,689
protected function resolveConflict ( $ id , $ vClock , array $ objectList ) { $ winner = $ objectList [ count ( $ objectList ) - 1 ] ; $ putInput = new Input \ PutInput ( ) ; $ putInput -> setVClock ( $ vClock ) ; $ mergedObject = new RiakObject ( $ id ) ; $ mergedObject -> setContent ( $ winner -> getContent ( ) ) ; $...
On - read conflict resolution . Applied approach here is last write wins . Specific needs may override this method to apply alternate conflict resolutions .
44,690
private function getNamespacedId ( string $ id ) : string { $ namespaceVersion = $ this -> getNamespaceVersion ( ) ; return sprintf ( '%s[%s][%s]' , $ this -> namespace , $ id , $ namespaceVersion ) ; }
Prefixes the passed id with the configured namespace value .
44,691
protected function doFetchMultiple ( array $ keys ) { $ returnValues = [ ] ; foreach ( $ keys as $ key ) { $ item = $ this -> doFetch ( $ key ) ; if ( $ item === false && ! $ this -> doContains ( $ key ) ) { continue ; } $ returnValues [ $ key ] = $ item ; } return $ returnValues ; }
Default implementation of doFetchMultiple . Each driver that supports multi - get should owerwrite it .
44,692
protected function doSaveMultiple ( array $ keysAndValues , $ lifetime = 0 ) { $ success = true ; foreach ( $ keysAndValues as $ key => $ value ) { if ( $ this -> doSave ( $ key , $ value , $ lifetime ) ) { continue ; } $ success = false ; } return $ success ; }
Default implementation of doSaveMultiple . Each driver that supports multi - put should override it .
44,693
private function getParsedBody ( Request $ request ) : array { $ body = $ request -> getContent ( ) ; $ contentType = \ explode ( ';' , ( string ) $ request -> headers -> get ( 'content-type' ) , 2 ) [ 0 ] ; switch ( $ contentType ) { case static :: CONTENT_TYPE_GRAPHQL : $ parsedBody = [ static :: PARAM_QUERY => $ bod...
Gets the body from the request based on Content - Type header .
44,694
private function getParams ( Request $ request , array $ data = [ ] ) : array { $ data = \ array_filter ( $ data ) + [ static :: PARAM_QUERY => null , static :: PARAM_VARIABLES => null , static :: PARAM_OPERATION_NAME => null , ] ; $ qs = $ request -> query ; $ query = $ qs -> has ( static :: PARAM_QUERY ) ? $ qs -> ge...
Gets the GraphQL parameters from the request .
44,695
private function convertException ( $ rawException = null ) { if ( null === $ rawException || $ rawException instanceof ClientAware ) { return $ rawException ; } $ errorClass = $ this -> findErrorClass ( $ rawException ) ; if ( null !== $ errorClass ) { return new $ errorClass ( $ rawException -> getMessage ( ) , $ raw...
Tries to convert a raw exception into a user warning or error that is displayed to the user .
44,696
private function treatFieldsDefaultAccess ( ArrayNodeDefinition $ node ) : void { $ node -> validate ( ) -> ifTrue ( function ( $ v ) { return \ array_key_exists ( 'fieldsDefaultAccess' , $ v ) && null !== $ v [ 'fieldsDefaultAccess' ] ; } ) -> then ( function ( $ v ) { foreach ( $ v [ 'fields' ] as & $ field ) { if ( ...
set empty fields . access with fieldsDefaultAccess values if is set?
44,697
private static function getAnnotationReader ( ) { if ( null === self :: $ annotationReader ) { if ( ! \ class_exists ( '\\Doctrine\\Common\\Annotations\\AnnotationReader' ) || ! \ class_exists ( '\\Doctrine\\Common\\Annotations\\AnnotationRegistry' ) ) { throw new \ Exception ( 'In order to use graphql annotation, you ...
Retrieve annotation reader .
44,698
private static function getGraphqlType ( GQL \ Type $ typeAnnotation , array $ classAnnotations , array $ properties , array $ methods , string $ namespace , string $ currentValue ) { $ typeConfiguration = [ ] ; $ fields = self :: getGraphqlFieldsFromAnnotations ( $ namespace , $ properties , false , false , $ currentV...
Create a GraphQL Type configuration from annotations on class properties and methods .
44,699
private static function getGraphqlInterface ( GQL \ TypeInterface $ interfaceAnnotation , array $ classAnnotations , array $ properties , array $ methods , string $ namespace ) { $ interfaceConfiguration = [ ] ; $ fields = self :: getGraphqlFieldsFromAnnotations ( $ namespace , $ properties ) ; $ fields = self :: getGr...
Create a GraphQL Interface type configuration from annotations on properties .