idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
35,200
private function extractFrameMeta ( $ source ) { $ headers = preg_split ( "/(\r?\n)+/" , $ source ) ; $ this -> command = array_shift ( $ headers ) ; foreach ( $ headers as $ header ) { $ headerDetails = explode ( ':' , $ header , 2 ) ; $ name = $ this -> decodeHeaderValue ( $ headerDetails [ 0 ] ) ; $ value = isset ( ...
Extracts command and headers from given header source .
35,201
public function flushBuffer ( ) { $ this -> expectedBodyLength = null ; $ this -> headers = [ ] ; $ this -> mode = self :: MODE_HEADER ; $ currentBuffer = substr ( $ this -> buffer , $ this -> offset ) ; $ this -> offset = 0 ; $ this -> bufferSize = 0 ; $ this -> buffer = '' ; return $ currentBuffer ; }
Resets the current buffer within this parser and returns the flushed buffer value .
35,202
public function addObserver ( ConnectionObserver $ observer ) { if ( ! in_array ( $ observer , $ this -> observers , true ) ) { $ this -> observers [ ] = $ observer ; } return $ this ; }
Adds new observers to the collection .
35,203
public function removeObserver ( ConnectionObserver $ observer ) { $ index = array_search ( $ observer , $ this -> observers , true ) ; if ( $ index !== false ) { unset ( $ this -> observers [ $ index ] ) ; } return $ this ; }
Removes the observers from the collection .
35,204
public function receivedFrame ( Frame $ frame ) { foreach ( $ this -> observers as $ item ) { $ item -> receivedFrame ( $ frame ) ; } }
Indicates that a frame has been received .
35,205
public function sentFrame ( Frame $ frame ) { foreach ( $ this -> observers as $ item ) { $ item -> sentFrame ( $ frame ) ; } }
Indicates that a frame has been transmitted .
35,206
public function activate ( ) { if ( ! $ this -> active ) { $ this -> client -> sendFrame ( $ this -> getProtocol ( ) -> getSubscribeFrame ( $ this -> subscription -> getDestination ( ) , $ this -> subscription -> getSubscriptionId ( ) , $ this -> subscription -> getAck ( ) , $ this -> subscription -> getSelector ( ) , ...
Init the subscription .
35,207
public function deactivate ( ) { if ( $ this -> active ) { $ this -> inactive ( ) ; $ this -> client -> sendFrame ( $ this -> getProtocol ( ) -> getUnsubscribeFrame ( $ this -> subscription -> getDestination ( ) , $ this -> subscription -> getSubscriptionId ( ) , true ) ) ; $ this -> active = false ; } }
Permanently remove durable subscription .
35,208
public static function generateId ( ) { while ( $ rand = rand ( 1 , PHP_INT_MAX ) ) { if ( ! in_array ( $ rand , static :: $ generatedIds , true ) ) { static :: $ generatedIds [ ] = $ rand ; return $ rand ; } } }
Generate a not used id .
35,209
public static function releaseId ( $ generatedId ) { $ index = array_search ( $ generatedId , static :: $ generatedIds , true ) ; if ( $ index !== false ) { unset ( static :: $ generatedIds [ $ index ] ) ; } }
Removes a previous generated id from currently used ids .
35,210
public function getSubscription ( Frame $ frame ) { foreach ( $ this -> subscriptions as $ subscription ) { if ( $ subscription -> belongsTo ( $ frame ) ) { return $ subscription ; } } return false ; }
Returns the subscription the frame belongs to or false if no matching subscription was found .
35,211
public function subscribe ( $ destination , $ subscriptionId = null , $ ack = 'auto' , $ selector = null , array $ header = [ ] ) { return $ this -> client -> sendFrame ( $ this -> getProtocol ( ) -> getSubscribeFrame ( $ destination , $ subscriptionId , $ ack , $ selector ) -> addHeaders ( $ header ) ) ; }
Register to listen to a given destination
35,212
public function unsubscribe ( $ destination , $ subscriptionId = null , array $ header = [ ] ) { return $ this -> client -> sendFrame ( $ this -> getProtocol ( ) -> getUnsubscribeFrame ( $ destination , $ subscriptionId ) -> addHeaders ( $ header ) ) ; }
Remove an existing subscription
35,213
public function commit ( $ transactionId = null ) { return $ this -> client -> sendFrame ( $ this -> getProtocol ( ) -> getCommitFrame ( $ transactionId ) ) ; }
Commit a transaction in progress
35,214
public function abort ( $ transactionId = null ) { return $ this -> client -> sendFrame ( $ this -> getProtocol ( ) -> getAbortFrame ( $ transactionId ) ) ; }
Roll back a transaction in progress
35,215
protected function endSubscription ( $ subscriptionId = null ) { if ( ! $ subscriptionId ) { $ subscriptionId = $ this -> subscriptions -> getLast ( ) -> getSubscriptionId ( ) ; } if ( ! isset ( $ this -> subscriptions [ $ subscriptionId ] ) ) { throw new InvalidArgumentException ( sprintf ( '%s is no active subscripti...
Closes given subscription or last opened .
35,216
private function getConnectedFrame ( ) { $ deadline = microtime ( true ) + $ this -> getConnection ( ) -> getConnectTimeout ( ) ; do { if ( $ frame = $ this -> connection -> readFrame ( ) ) { return $ frame ; } } while ( microtime ( true ) <= $ deadline ) ; return null ; }
Returns the next available frame from the connection respecting the connect timeout .
35,217
public function send ( $ destination , $ msg , array $ header = [ ] , $ sync = null ) { if ( ! $ msg instanceof Frame ) { return $ this -> send ( $ destination , new Frame ( 'SEND' , $ header , $ msg ) , [ ] , $ sync ) ; } $ msg -> addHeaders ( $ header ) ; $ msg [ 'destination' ] = $ destination ; return $ this -> sen...
Send a message to a destination in the messaging system
35,218
public function sendFrame ( Frame $ frame , $ sync = null ) { if ( ! $ this -> isConnecting && ! $ this -> isConnected ( ) ) { $ this -> connect ( ) ; } $ writeSync = $ sync !== null ? $ sync : $ this -> sync ; if ( $ writeSync ) { return $ this -> sendFrameExpectingReceipt ( $ frame ) ; } else { return $ this -> conne...
Send a frame .
35,219
protected function sendFrameExpectingReceipt ( Frame $ stompFrame ) { $ receipt = md5 ( microtime ( ) ) ; $ stompFrame [ 'receipt' ] = $ receipt ; $ this -> connection -> writeFrame ( $ stompFrame ) ; return $ this -> waitForReceipt ( $ receipt ) ; }
Write frame to server and expect an matching receipt frame
35,220
protected function waitForReceipt ( $ receipt ) { $ stopAfter = $ this -> calculateReceiptWaitEnd ( ) ; while ( true ) { if ( $ frame = $ this -> connection -> readFrame ( ) ) { if ( $ frame -> getCommand ( ) == 'RECEIPT' ) { if ( $ frame [ 'receipt-id' ] == $ receipt ) { return true ; } else { throw new UnexpectedResp...
Wait for an receipt
35,221
public function disconnect ( $ sync = false ) { try { if ( $ this -> connection && $ this -> connection -> isConnected ( ) ) { if ( $ this -> protocol ) { $ this -> sendFrame ( $ this -> protocol -> getDisconnectFrame ( ) , $ sync ) ; } } } catch ( StompException $ ex ) { } if ( $ this -> connection ) { $ this -> conne...
Graceful disconnect from the server
35,222
protected function initTransaction ( array $ options = [ ] ) { if ( ! isset ( $ options [ 'transactionId' ] ) ) { $ this -> transactionId = IdGenerator :: generateId ( ) ; $ this -> getClient ( ) -> sendFrame ( $ this -> getProtocol ( ) -> getBeginFrame ( $ this -> transactionId ) ) ; } else { $ this -> transactionId =...
Init the transaction state .
35,223
public function send ( $ destination , Message $ message ) { return $ this -> getClient ( ) -> send ( $ destination , $ message , [ 'transaction' => $ this -> transactionId ] , false ) ; }
Send a message within this transaction .
35,224
protected function transactionCommit ( ) { $ this -> getClient ( ) -> sendFrame ( $ this -> getProtocol ( ) -> getCommitFrame ( $ this -> transactionId ) ) ; IdGenerator :: releaseId ( $ this -> transactionId ) ; }
Commit current transaction .
35,225
protected function transactionAbort ( ) { $ this -> getClient ( ) -> sendFrame ( $ this -> getProtocol ( ) -> getAbortFrame ( $ this -> transactionId ) ) ; IdGenerator :: releaseId ( $ this -> transactionId ) ; }
Abort the current transaction .
35,226
public function subscribe ( $ destination , $ selector = null , $ ack = 'auto' , array $ header = [ ] ) { return $ this -> state -> subscribe ( $ destination , $ selector , $ ack , $ header ) ; }
Subscribe to given destination .
35,227
public function isDelayed ( ) { if ( $ this -> enabled && $ this -> lastbeat ) { $ now = microtime ( true ) ; return ( $ now - $ this -> lastbeat > $ this -> intervalUsed ) ; } return false ; }
Returns if the emitter is in a state that indicates a delay .
35,228
private function enable ( Frame $ frame ) { $ this -> onHeartbeatFrame ( $ frame , $ this -> getHeartbeats ( $ frame ) ) ; if ( $ this -> intervalServer && $ this -> intervalClient ) { $ intervalAgreement = $ this -> calculateInterval ( max ( $ this -> intervalClient , $ this -> intervalServer ) ) ; $ this -> intervalU...
Enables the delay detection when preconditions are fulfilled .
35,229
public function handle ( $ model ) { if ( ! $ model -> isUserstamping ( ) ) { return ; } if ( is_null ( $ model -> { $ model -> getCreatedByColumn ( ) } ) ) { $ model -> { $ model -> getCreatedByColumn ( ) } = auth ( ) -> id ( ) ; } if ( is_null ( $ model -> { $ model -> getUpdatedByColumn ( ) } ) && ! is_null ( $ mode...
When the model is being created .
35,230
public function handle ( $ model ) { if ( ! $ model -> isUserstamping ( ) ) { return ; } if ( is_null ( $ model -> { $ model -> getDeletedByColumn ( ) } ) ) { $ model -> { $ model -> getDeletedByColumn ( ) } = auth ( ) -> id ( ) ; } $ dispatcher = $ model -> getEventDispatcher ( ) ; $ model -> unsetEventDispatcher ( ) ...
When the model is being deleted .
35,231
protected function getUserClass ( ) { if ( get_class ( auth ( ) ) === 'Illuminate\Auth\Guard' ) { return auth ( ) -> getProvider ( ) -> getModel ( ) ; } return auth ( ) -> guard ( ) -> getProvider ( ) -> getModel ( ) ; }
Get the class being used to provide a User .
35,232
public function handle ( $ model ) { if ( ! $ model -> isUserstamping ( ) || is_null ( $ model -> getUpdatedByColumn ( ) ) ) { return ; } $ model -> { $ model -> getUpdatedByColumn ( ) } = auth ( ) -> id ( ) ; }
When the model is being updated .
35,233
public function getSql ( ) { if ( $ this -> builtSql === null ) { $ this -> builtSql = $ this -> buildSql ( ) ; } return $ this -> builtSql ; }
Get the constructed and escaped sql string .
35,234
public function prepend ( $ str ) { $ this -> buffer = $ str . \ substr ( $ this -> buffer , $ this -> bufferPos ) ; $ this -> bufferPos = 0 ; }
prepends some data to start of buffer and resets buffer position to start
35,235
public function read ( $ len ) { if ( $ len === 0 ) { return '' ; } if ( $ len === 1 && isset ( $ this -> buffer [ $ this -> bufferPos ] ) ) { return $ this -> buffer [ $ this -> bufferPos ++ ] ; } if ( $ len < 0 || ! isset ( $ this -> buffer [ $ this -> bufferPos + $ len - 1 ] ) ) { throw new \ LogicException ( 'Not e...
Reads binary string data with given byte length from buffer
35,236
public function skip ( $ len ) { if ( $ len < 1 || ! isset ( $ this -> buffer [ $ this -> bufferPos + $ len - 1 ] ) ) { throw new \ LogicException ( 'Not enough data in buffer' ) ; } $ this -> bufferPos += $ len ; }
Skips binary string data with given byte length from buffer
35,237
public function trim ( ) { if ( ! isset ( $ this -> buffer [ $ this -> bufferPos ] ) ) { $ this -> buffer = '' ; } else { $ this -> buffer = \ substr ( $ this -> buffer , $ this -> bufferPos ) ; } $ this -> bufferPos = 0 ; }
Clears all consumed data from the buffer
35,238
public function readStringLen ( ) { $ l = $ this -> readIntLen ( ) ; if ( $ l === null ) { return $ l ; } return $ this -> read ( $ l ) ; }
Parses length - encoded binary string
35,239
public function readStringNull ( ) { $ pos = \ strpos ( $ this -> buffer , "\0" , $ this -> bufferPos ) ; if ( $ pos === false ) { throw new \ LogicException ( 'Missing NULL character' ) ; } $ ret = $ this -> read ( $ pos - $ this -> bufferPos ) ; ++ $ this -> bufferPos ; return $ ret ; }
Reads string until NULL character
35,240
protected function createRole ( $ roleName ) { $ role = $ this -> roleRepository -> create ( $ roleName ) ; $ this -> info ( 'Role created successfully' ) ; return $ role ; }
Create role .
35,241
protected function attachRoleToUser ( $ role , $ userId ) { if ( $ user = $ this -> userRepository -> findById ( $ userId ) ) { $ user -> attachRole ( $ role ) ; $ this -> info ( 'Role attached successfully to user' ) ; } else { $ this -> error ( 'Not possible to attach role. User not found' ) ; } }
Attach role to user .
35,242
protected function createPermission ( $ name , $ readableName ) { $ permission = $ this -> permissionRepository -> create ( $ name , $ readableName ) ; $ this -> info ( 'Permission created successfully' ) ; return $ permission ; }
Create permission .
35,243
protected function attachPermissionToUser ( $ permission , $ userId ) { if ( $ user = $ this -> userRepository -> findById ( $ userId ) ) { $ user -> attachPermission ( $ permission ) ; $ this -> info ( 'Permission attached successfully to user' ) ; } else { $ this -> error ( 'Not possible to attach permission. User no...
Attach Permission to user .
35,244
public function attachPermission ( $ permission , array $ options = [ ] ) { if ( ! is_array ( $ permission ) ) { if ( $ this -> existPermission ( $ permission -> name ) ) { return ; } } $ this -> permissions ( ) -> attach ( $ permission , [ 'value' => array_get ( $ options , 'value' , true ) , 'expires' => array_get ( ...
Attach the given permission .
35,245
public function existPermission ( $ permissionName ) { $ permission = $ this -> permissions -> first ( function ( $ key , $ value ) use ( $ permissionName ) { return ( ( isset ( $ key -> name ) ) ? $ key -> name : $ value -> name ) == $ permissionName ; } ) ; if ( ! empty ( $ permission ) ) { $ active = ( is_null ( $ p...
Get the a permission using the permission name .
35,246
public function revokeExpiredPermissions ( ) { $ expiredPermissions = $ this -> permissions ( ) -> wherePivot ( 'expires' , '<' , Carbon :: now ( ) ) -> get ( ) ; if ( $ expiredPermissions -> count ( ) > 0 ) { return $ this -> permissions ( ) -> detach ( $ expiredPermissions -> modelKeys ( ) ) ; } }
Revoke expired user permissions .
35,247
public function extendPermission ( $ permission , array $ options ) { foreach ( $ this -> permissions as $ _permission ) { if ( $ _permission -> name === $ permission ) { return $ this -> permissions ( ) -> updateExistingPivot ( $ _permission -> id , array_only ( $ options , [ 'value' , 'expires' ] ) ) ; } } }
Extend an existing temporary permission .
35,248
public function permissions ( ) { $ permissionModel = config ( 'defender.permission_model' ) ; $ permissionRoleTable = config ( 'defender.permission_role_table' ) ; $ roleKey = config ( 'defender.role_key' ) ; $ permissionKey = config ( 'defender.permission_key' ) ; return $ this -> belongsToMany ( $ permissionModel , ...
Many - to - many permission - user relationship .
35,249
protected function forbiddenResponse ( ) { $ handler = app ( ) -> make ( config ( 'defender.forbidden_callback' ) ) ; return ( $ handler instanceof ForbiddenHandler ) ? $ handler -> handle ( ) : response ( 'Forbidden' , 403 ) ; }
Handles the forbidden response .
35,250
public function roleHasPermission ( $ permission , $ force = false ) { if ( ! is_null ( $ this -> getUser ( ) ) ) { return $ this -> getUser ( ) -> roleHasPermission ( $ permission , $ force ) ; } return false ; }
Check if the authenticated user has the given permission using only the roles .
35,251
public function hasRoles ( $ roles ) { if ( ! is_null ( $ this -> getUser ( ) ) ) { return $ this -> getUser ( ) -> hasRoles ( $ roles ) ; } return false ; }
Return if the authenticated user has any of the given roles .
35,252
protected function registerRepositoryInterfaces ( ) { $ this -> app -> bind ( 'Artesaos\Defender\Contracts\Permission' , function ( $ app ) { return $ app -> make ( $ this -> app [ 'config' ] -> get ( 'defender.permission_model' ) ) ; } ) ; $ this -> app -> bind ( 'Artesaos\Defender\Contracts\Role' , function ( $ app )...
Bind repositories interfaces with their implementations .
35,253
protected function registerBladeExtensions ( ) { if ( false === $ this -> app [ 'config' ] -> get ( 'defender.template_helpers' , true ) ) { return ; } $ this -> app -> afterResolving ( 'blade.compiler' , function ( BladeCompiler $ bladeCompiler ) { $ bladeCompiler -> directive ( 'shield' , function ( $ expression ) { ...
Register new blade extensions .
35,254
private function setUserModelConfig ( ) { if ( config ( 'defender.user_model' ) == '' ) { if ( str_contains ( $ this -> app -> version ( ) , '5.1' ) ) { return config ( [ 'defender.user_model' => $ this -> app [ 'auth' ] -> getProvider ( ) -> getModel ( ) ] ) ; } return config ( [ 'defender.user_model' => $ this -> app...
Set the default configuration for the user model .
35,255
public function create ( $ permissionName , $ readableName = null ) { if ( ! is_null ( $ this -> findByName ( $ permissionName ) ) ) { throw new PermissionExistsException ( 'The permission ' . $ permissionName . ' already exists' ) ; } $ readableName = is_null ( $ readableName ) ? $ permissionName : $ readableName ; re...
Create a new permission using the given name .
35,256
public function hasPermission ( $ permission , $ force = false ) { $ permissions = $ this -> getAllPermissions ( $ force ) -> pluck ( 'name' ) -> toArray ( ) ; if ( strpos ( $ permission , '*' ) ) { $ permission = substr ( $ permission , 0 , - 2 ) ; return ( bool ) preg_grep ( '~' . $ permission . '~' , $ permissions )...
Returns if the current user has the given permission . User permissions override role permissions .
35,257
public function hasPermissions ( array $ permissions , $ strict = true , $ force = false ) { $ allPermissions = $ this -> getAllPermissions ( $ force ) -> pluck ( 'name' ) -> toArray ( ) ; $ equalPermissions = array_intersect ( $ permissions , $ allPermissions ) ; $ countEqual = count ( $ equalPermissions ) ; if ( $ co...
Returns if the current user has all or one permission of the given array . User permissions override role permissions .
35,258
public function canDo ( $ permission , $ force = false ) { if ( $ this -> isSuperUser ( ) ) { return true ; } return $ this -> hasPermission ( $ permission , $ force ) ; }
Checks for permission If has superuser group automatically passes .
35,259
public function roleHasPermission ( $ permission , $ force = false ) { $ permissions = $ this -> getRolesPermissions ( $ force ) -> pluck ( 'name' ) -> toArray ( ) ; return in_array ( $ permission , $ permissions ) ; }
Check if the user has the given permission using only his roles .
35,260
public function getAllPermissions ( $ force = false ) { if ( empty ( $ this -> cachedPermissions ) or $ force ) { $ this -> cachedPermissions = $ this -> getFreshAllPermissions ( ) ; } return $ this -> cachedPermissions ; }
Retrieve all user permissions .
35,261
public function getRolesPermissions ( $ force = false ) { if ( empty ( $ this -> cachedRolePermissions ) or $ force ) { $ this -> cachedRolePermissions = $ this -> getFreshRolesPermissions ( ) ; } return $ this -> cachedRolePermissions ; }
Get permissions from database based on roles .
35,262
protected function getFreshRolesPermissions ( ) { $ roles = $ this -> roles ( ) -> get ( [ 'id' ] ) -> pluck ( 'id' ) -> toArray ( ) ; return app ( 'defender.permission' ) -> getByRoles ( $ roles ) ; }
Get fresh permissions from database based on roles .
35,263
protected function getFreshAllPermissions ( ) { $ permissionsRoles = $ this -> getRolesPermissions ( true ) ; $ permissions = app ( 'defender.permission' ) -> getActivesByUser ( $ this ) ; $ permissions = $ permissions -> merge ( $ permissionsRoles ) -> map ( function ( $ permission ) { unset ( $ permission -> pivot , ...
Get fresh permissions from database .
35,264
public function create ( $ roleName ) { if ( ! is_null ( $ this -> findByName ( $ roleName ) ) ) { throw new RoleExistsException ( 'A role with the given name already exists' ) ; } return $ role = $ this -> model -> create ( [ 'name' => $ roleName ] ) ; }
Create a new role with the given name .
35,265
public function hasRoles ( $ roles ) { $ roles = is_array ( $ roles ) ? $ roles : func_get_args ( ) ; foreach ( $ roles as $ role ) { if ( $ this -> hasRole ( $ role ) ) { return true ; } } return false ; }
Returns true if the given user has any of the given roles .
35,266
public function attachRole ( $ role ) { if ( ! $ this -> hasRole ( $ role -> name ) ) { $ this -> roles ( ) -> attach ( $ role ) ; } }
Attach the given role .
35,267
public function roles ( ) { $ roleModel = config ( 'defender.role_model' , 'Artesaos\Defender\Role' ) ; $ roleUserTable = config ( 'defender.role_user_table' , 'role_user' ) ; $ roleKey = config ( 'defender.role_key' , 'role_id' ) ; return $ this -> belongsToMany ( $ roleModel , $ roleUserTable , 'user_id' , $ roleKey ...
Many - to - many role - user relationship .
35,268
public function scopeWhichRoles ( $ query , $ roles ) { return $ query -> whereHas ( 'roles' , function ( $ query ) use ( $ roles ) { $ roles = ( is_array ( $ roles ) ) ? $ roles : [ $ roles ] ; $ query -> whereIn ( 'name' , $ roles ) ; } ) ; }
Take user by roles .
35,269
public function createPath ( $ filename ) { $ dir = Config :: get ( 'js-localization.storage_path' ) ; if ( ! is_dir ( $ dir ) ) { mkdir ( $ dir , 0777 , true ) ; } return $ dir . $ filename ; }
Create full file path . This method will also generate the directories if they don t exist already .
35,270
public function generateMessagesFile ( $ path , $ noCache = false ) { $ splitFiles = Config :: get ( 'js-localization.split_export_files' ) ; $ messages = MessageCachingService :: getMessagesJson ( $ noCache ) ; if ( $ splitFiles ) { $ this -> generateMessageFiles ( File :: dirname ( $ path ) , $ messages ) ; } $ conte...
Generate the messages file .
35,271
public function generateConfigFile ( $ path , $ noCache = false ) { $ config = ConfigCachingService :: getConfigJson ( $ noCache ) ; if ( $ config === '{}' ) { $ this -> line ( 'No config specified. Config not written to file.' ) ; return ; } $ contents = 'Config.addConfig(' . $ config . ');' ; File :: put ( $ path , $...
Generate the config file .
35,272
public function refreshCacheUsing ( $ data ) { Cache :: forever ( $ this -> cacheKey , $ data ) ; Cache :: forever ( $ this -> cacheTimestampKey , time ( ) ) ; }
Refresh the cached data .
35,273
public function getData ( ) { if ( ! Cache :: has ( $ this -> cacheKey ) ) { $ this -> refreshCache ( ) ; } return Cache :: get ( $ this -> cacheKey ) ; }
Return the cached data . Refresh cache if cache has not yet been initialized .
35,274
protected function getTranslatedMessagesForLocales ( array $ messageKeys , array $ locales ) { $ translatedMessages = [ ] ; foreach ( $ locales as $ locale ) { if ( ! isset ( $ translatedMessages [ $ locale ] ) ) { $ translatedMessages [ $ locale ] = [ ] ; } $ translatedMessages [ $ locale ] = $ this -> getTranslatedMe...
Returns the translated messages for the given keys and locales .
35,275
protected function getTranslatedMessages ( array $ messageKeys , $ locale ) { $ translatedMessages = [ ] ; foreach ( $ messageKeys as $ key ) { $ translation = Lang :: get ( $ key , [ ] , $ locale ) ; if ( is_array ( $ translation ) ) { $ flattened = $ this -> flattenTranslations ( $ translation , $ key . '.' ) ; $ tra...
Returns the translated messages for the given keys .
35,276
protected function getMessageKeys ( ) { $ messageKeys = Config :: get ( 'js-localization.messages' ) ; $ messageKeys = JsLocalizationHelper :: resolveMessageKeyArray ( $ messageKeys ) ; $ messageKeys = array_unique ( array_merge ( $ messageKeys , JsLocalizationHelper :: getAdditionalMessages ( ) ) ) ; return $ messageK...
Returns the message keys of all messages that are supposed to be sent to the browser .
35,277
public function resolveMessageKeyArray ( array $ messageKeys ) { $ flatArray = [ ] ; foreach ( $ messageKeys as $ index => $ key ) { $ this -> resolveMessageKey ( $ key , $ index , function ( $ qualifiedKey ) use ( & $ flatArray ) { $ flatArray [ ] = $ qualifiedKey ; } ) ; } return $ flatArray ; }
Takes an array of message keys with nested sub - arrays and returns a flat array of fully qualified message keys .
35,278
public function resolveMessageArrayToMessageKeys ( array $ messages , $ prefix = "" ) { $ flatArray = [ ] ; foreach ( $ messages as $ key => $ message ) { $ this -> resolveMessageToKeys ( $ message , $ key , function ( $ qualifiedKey ) use ( & $ flatArray ) { $ flatArray [ ] = $ qualifiedKey ; } , $ prefix ) ; } return...
Resolves a message array with nested sub - arrays to a flat array of fully qualified message keys .
35,279
private function resolveMessageKey ( $ key , $ keyIndex , $ callback , $ prefix = "" ) { if ( is_array ( $ key ) ) { $ _prefix = $ prefix ? $ prefix . $ keyIndex . "." : $ keyIndex . "." ; foreach ( $ key as $ _index => $ _key ) { $ this -> resolveMessageKey ( $ _key , $ _index , $ callback , $ _prefix ) ; } } else { $...
Returns the concatenation of prefix and key if the key is a string . If the key is an array then the function will recurse .
35,280
private function resolveMessageToKeys ( $ message , $ key , $ callback , $ prefix = "" ) { if ( is_array ( $ message ) ) { $ _prefix = $ prefix ? $ prefix . $ key . "." : $ key . "." ; foreach ( $ message as $ _key => $ _message ) { $ this -> resolveMessageToKeys ( $ _message , $ _key , $ callback , $ _prefix ) ; } } e...
Returns the concatenation of prefix and key if the value is a message . If the value is an array then the function will recurse .
35,281
private function prefix ( $ prefix ) { if ( $ prefix ) { $ prefixLastChar = substr ( $ prefix , - 1 ) ; if ( $ prefixLastChar != '.' && $ prefixLastChar != ':' ) { $ prefix .= '.' ; } } return $ prefix ; }
Appends a dot to the prefix if necessary .
35,282
public function createJsMessages ( ) { $ contents = $ this -> getMessagesJson ( ) ; return response ( $ contents ) -> header ( 'Content-Type' , 'text/javascript' ) -> setLastModified ( MessageCachingService :: getLastRefreshTimestamp ( ) ) ; }
Create the JS - Response for all configured translation messages
35,283
public function deliverAllInOne ( ) { $ contents = file_get_contents ( __DIR__ . "/../../../public/js/localization.min.js" ) ; $ contents .= "\n" ; $ contents .= $ this -> getMessagesJson ( ) ; $ contents .= $ this -> getConfigJson ( ) ; $ response = response ( $ contents ) ; $ response -> header ( 'Content-Type' , 'te...
Deliver one file that combines messages and framework . Saves one additional HTTP - Request
35,284
protected function getMessagesJson ( ) { $ messages = MessageCachingService :: getMessagesJson ( ) ; $ messages = $ this -> ensureBackwardsCompatibility ( $ messages ) ; $ contents = 'Lang.addMessages(' . $ messages . ');' ; return $ contents ; }
Get the configured messages from the translation files
35,285
private function resetComposers ( ComposerApplication $ application ) { $ application -> resetComposer ( ) ; foreach ( $ this -> getApplication ( ) -> all ( ) as $ command ) { if ( $ command instanceof BaseCommand ) { $ command -> resetComposer ( ) ; } } }
Resets all Composer references in the application .
35,286
public function get ( Pagination $ pagination = null , Filters $ filters = null , $ qParam = '' ) { return $ this -> getByPath ( $ this -> generateListPath ( $ pagination , $ filters , [ 'q' => $ qParam ] ) ) ; }
Get an order list in MoIP .
35,287
protected function populate ( stdClass $ response ) { $ entry = clone $ this ; $ entry -> data -> id = $ this -> getIfSet ( 'id' , $ response ) ; $ entry -> data -> status = $ this -> getIfSet ( 'status' , $ response ) ; $ entry -> data -> operation = $ this -> getIfSet ( 'operation' , $ response ) ; if ( isset ( $ res...
Mount the entry .
35,288
public function get ( $ id_moip ) { return $ this -> getByPath ( sprintf ( '/%s/%s/%s/' , MoipResource :: VERSION , self :: PATH , $ id_moip ) ) ; }
Get entry in api by id .
35,289
protected function populate ( stdClass $ response ) { $ webhookList = clone $ this ; $ webhookList -> data = new stdClass ( ) ; $ webhookList -> data -> webhooks = $ response -> webhooks ; return $ webhookList ; }
Mount structure of Webhook List .
35,290
public function setAddress ( $ type , $ street , $ number , $ district , $ city , $ state , $ zip , $ complement = null , $ country = self :: ADDRESS_COUNTRY ) { $ address = new stdClass ( ) ; $ address -> street = $ street ; $ address -> streetNumber = $ number ; $ address -> complement = $ complement ; $ address -> d...
Add a new address to the holder .
35,291
protected function populate ( stdClass $ response ) { $ holder = clone $ this ; $ holder -> data = new stdClass ( ) ; $ holder -> data -> fullname = $ this -> getIfSet ( 'fullname' , $ response ) ; $ holder -> data -> phone = new stdClass ( ) ; $ phone = $ this -> getIfSet ( 'phone' , $ response ) ; $ holder -> data ->...
Mount the buyer structure from holder .
35,292
public function setBirthDate ( $ birthDate ) { if ( $ birthDate instanceof \ DateTime ) { $ birthDate = $ birthDate -> format ( 'Y-m-d' ) ; } $ this -> data -> birthDate = $ birthDate ; return $ this ; }
Set birth date from holder .
35,293
public function setTaxDocument ( $ number , $ type = self :: TAX_DOCUMENT ) { $ this -> data -> taxDocument = new stdClass ( ) ; $ this -> data -> taxDocument -> type = $ type ; $ this -> data -> taxDocument -> number = $ number ; return $ this ; }
Set tax document from holder .
35,294
public function before_request ( & $ url , & $ headers , & $ data , & $ type , & $ options ) { $ headers [ 'Authorization' ] = 'Basic ' . base64_encode ( $ this -> token . ':' . $ this -> key ) ; }
Sets the authentication header .
35,295
protected function populate ( stdClass $ response ) { $ balances = clone $ this ; $ balances -> data -> unavailable = $ this -> getIfSet ( 'unavailable' , $ response ) ? : [ ] ; $ balances -> data -> future = $ this -> getIfSet ( 'future' , $ response ) ? : [ ] ; $ balances -> data -> current = $ this -> getIfSet ( 'cu...
Populate this instance .
35,296
public function get ( ) { $ path = sprintf ( '/%s/%s' , MoipResource :: VERSION , self :: PATH ) ; return $ this -> getByPath ( $ path , [ 'Accept' => static :: ACCEPT_VERSION ] ) ; }
Get all balances .
35,297
protected function getIfSet ( $ key , stdClass $ data = null ) { if ( empty ( $ data ) ) { $ data = $ this -> data ; } if ( isset ( $ data -> $ key ) ) { return $ data -> $ key ; } }
Get a key of an object if it exists .
35,298
public function generatePath ( $ action , $ id = null ) { if ( ! is_null ( $ id ) ) { return sprintf ( '%s/%s/%s/%s' , self :: VERSION , static :: PATH , $ action , $ id ) ; } return sprintf ( '%s/%s/%s' , self :: VERSION , static :: PATH , $ action ) ; }
Generate URL to request .
35,299
public function generateListPath ( Pagination $ pagination = null , Filters $ filters = null , $ params = [ ] ) { $ queryParams = [ ] ; if ( ! is_null ( $ pagination ) ) { if ( $ pagination -> getLimit ( ) != 0 ) { $ queryParams [ 'limit' ] = $ pagination -> getLimit ( ) ; } if ( $ pagination -> getOffset ( ) >= 0 ) { ...
Generate URL to request a get list .