idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
2,200 | public static function createEmpty ( string $ scoreMode = self :: SUM ) : self { $ scoreStrategies = new self ( ) ; $ scoreStrategies -> scoreMode = $ scoreMode ; return $ scoreStrategies ; } | Create empty . |
2,201 | private function getAppKey ( ) : string { $ appUUID = $ this -> getRepositoryReference ( ) -> getAppUUID ( ) ; return $ appUUID instanceof AppUUID ? $ appUUID -> getId ( ) : '' ; } | Get app position by credentials . |
2,202 | public static function createByComposedUUID ( string $ composedUUID ) : self { $ parts = explode ( '~' , $ composedUUID ) ; if ( 2 !== count ( $ parts ) ) { throw InvalidFormatException :: composedItemUUIDNotValid ( $ composedUUID ) ; } return new self ( $ parts [ 0 ] , $ parts [ 1 ] ) ; } | Create by composed uuid . |
2,203 | public function addRetry ( Retry $ retry ) { $ this -> retries [ $ retry -> getUrl ( ) . '~~' . $ retry -> getMethod ( ) ] = $ retry ; } | Add retry . |
2,204 | public function getRetry ( string $ url , string $ method ) : ? Retry { $ url = trim ( trim ( strtolower ( $ url ) ) , '/' ) ; $ method = trim ( strtolower ( $ method ) ) ; if ( isset ( $ this -> retries [ $ url . '~~' . $ method ] ) ) { return $ this -> retries [ $ url . '~~' . $ method ] ; } if ( isset ( $ this -> re... | Check retry . |
2,205 | public static function fromMetadata ( string $ metadata ) : ? array { $ values = [ ] ; $ splittedParts = explode ( '~~' , $ metadata ) ; foreach ( $ splittedParts as $ part ) { $ parts = explode ( '##' , $ part ) ; if ( count ( $ parts ) > 1 ) { $ values [ $ parts [ 0 ] ] = $ parts [ 1 ] ; } else { $ values [ ] = $ par... | metadata format to array . |
2,206 | public static function stringToArray ( string $ string ) : array { list ( $ from , $ to ) = explode ( self :: SEPARATOR , $ string ) ; $ from = empty ( $ from ) ? self :: ZERO : ( is_numeric ( $ from ) ? ( int ) $ from : $ from ) ; $ to = empty ( $ to ) ? self :: INFINITE : ( is_numeric ( $ to ) ? ( int ) $ to : $ to )... | Get values given string . |
2,207 | public static function arrayToString ( array $ values ) : string { if ( self :: ZERO == $ values [ 0 ] ) { $ values [ 0 ] = '' ; } if ( self :: INFINITE == $ values [ 1 ] ) { $ values [ 1 ] = '' ; } return implode ( self :: SEPARATOR , $ values ) ; } | Get string given values . |
2,208 | public static function createRanges ( int $ from , int $ to , int $ incremental ) : array { $ ranges = [ ] ; while ( $ from < $ to ) { $ nextTo = $ from + $ incremental ; $ ranges [ ] = $ from . self :: SEPARATOR . $ nextTo ; $ from = $ nextTo ; } return $ ranges ; } | Create a set of ranges given a minimum a maximum and an incremental . |
2,209 | public static function getApisearchHeaders ( RepositoryWithCredentials $ repository ) : array { return [ self :: APP_ID_HEADER => $ repository -> getAppUUID ( ) -> composeUUID ( ) , self :: TOKEN_ID_HEADER => $ repository -> getTokenUUID ( ) -> composeUUID ( ) , ] ; } | Get common query values . |
2,210 | public static function fromFilterArray ( array $ array ) : LocationRange { $ coordinates = array_map ( function ( array $ coordinate ) { return Coordinate :: createFromArray ( $ coordinate ) ; } , $ array [ 'coordinates' ] ) ; return new Polygon ( $ coordinates ) ; } | From filter array . |
2,211 | public function deleteTokens ( ) { $ response = $ this -> httpClient -> get ( sprintf ( '/%s/tokens' , $ this -> getAppUUID ( ) -> getId ( ) ) , 'delete' , [ ] , [ ] , Http :: getApisearchHeaders ( $ this ) ) ; self :: throwTransportableExceptionIfNeeded ( $ response ) ; } | Delete all tokens . |
2,212 | public function addItem ( Item $ item ) { $ itemUUID = $ item -> composeUUID ( ) ; $ this -> elementsToUpdate [ $ itemUUID ] = $ item ; unset ( $ this -> elementsToDelete [ $ itemUUID ] ) ; } | Generate item document . |
2,213 | public function flush ( int $ bulkNumber = 500 , bool $ skipIfLess = false ) { if ( $ skipIfLess && count ( $ this -> elementsToUpdate ) < $ bulkNumber ) { return ; } $ offset = 0 ; try { while ( true ) { $ items = array_slice ( $ this -> elementsToUpdate , $ offset , $ bulkNumber ) ; if ( empty ( $ items ) ) { break ;... | Flush all . |
2,214 | public function hasNotEmptyAggregation ( string $ name ) : bool { return ! is_null ( $ this -> getAggregation ( $ name ) ) && ! $ this -> getAggregation ( $ name ) -> isEmpty ( ) ; } | Return if the needed aggregation exists and if is not empty . |
2,215 | public function get ( string $ url , string $ method , array $ query = [ ] , array $ body = [ ] , array $ server = [ ] ) : array { $ method = strtolower ( $ method ) ; $ requestParts = $ this -> buildRequestParts ( $ url , $ query , $ body , $ server ) ; return $ this -> tryRequest ( function ( ) use ( $ method , $ req... | Get a response given some parameters . Return an array with the status code and the body . |
2,216 | private function tryRequest ( callable $ callable , ? Retry $ retry ) : array { $ tries = $ retry instanceof Retry ? $ retry -> getRetries ( ) : 0 ; while ( true ) { try { return $ callable ( ) ; } catch ( \ Exception $ e ) { if ( $ tries -- <= 0 ) { throw $ e ; } usleep ( $ retry -> getMicrosecondsBetweenRetries ( ) )... | Try connection and return result . |
2,217 | public function addCounter ( string $ name , int $ counter ) { if ( 0 == $ counter ) { return ; } $ counterInstance = Counter :: createByActiveElements ( $ name , $ counter , $ this -> activeElements ) ; if ( ! $ counterInstance instanceof Counter ) { return ; } if ( $ this -> applicationType & Filter :: MUST_ALL_WITH_... | Add aggregation counter . |
2,218 | public function getActiveElements ( ) : array { if ( empty ( $ this -> activeElements ) ) { return [ ] ; } if ( Filter :: MUST_ALL_WITH_LEVELS === $ this -> applicationType ) { $ value = [ array_reduce ( $ this -> activeElements , function ( $ carry , $ counter ) { if ( ! $ counter instanceof Counter ) { return $ carry... | Get active elements . |
2,219 | public function cleanCountersByLevel ( ) { foreach ( $ this -> counters as $ pos => $ counter ) { if ( $ counter -> getLevel ( ) !== $ this -> highestActiveLevel + 1 ) { unset ( $ this -> counters [ $ pos ] ) ; } } } | Clean results by level and remove all levels higher than the lowest . |
2,220 | public function addInteraction ( Interaction $ interaction ) { $ response = $ this -> httpClient -> get ( sprintf ( '/%s/interactions' , $ this -> getAppUUID ( ) -> composeUUID ( ) ) , 'post' , [ ] , $ interaction -> toArray ( ) , Http :: getApisearchHeaders ( $ this ) ) ; self :: throwTransportableExceptionIfNeeded ( ... | Add interaction . |
2,221 | public function init ( ) { $ mode = $ this -> getProject ( ) -> getProperty ( 'includeresource.mode' ) ; if ( ! is_null ( $ mode ) ) { $ this -> setMode ( $ mode ) ; } } | Init tasks . |
2,222 | public function main ( ) { $ this -> validate ( ) ; if ( $ this -> dest -> exists ( ) ) { $ this -> log ( "Replacing existing resource '" . $ this -> dest -> getPath ( ) . "'" ) ; if ( $ this -> dest -> delete ( TRUE ) === FALSE ) { throw new BuildException ( "Failed to delete existing destination '$this->dest'" ) ; } ... | Copy or link the resource . |
2,223 | protected function loadCredentials ( ) { if ( empty ( $ this -> mail ) || empty ( $ this -> key ) ) { if ( empty ( $ this -> credentialsFile ) ) { $ this -> credentialsFile = new PhingFile ( $ _SERVER [ 'HOME' ] . '/.acquia/cloudapi.conf' ) ; } if ( ! file_exists ( $ this -> credentialsFile ) || ! is_readable ( $ this ... | Load the Acquia Cloud credentials from the cloudapi . conf JSON file . |
2,224 | protected function createRequest ( $ path ) { $ this -> loadCredentials ( ) ; $ uri = $ this -> endpoint . '/' . ltrim ( $ path , '/' ) ; $ request = new HTTP_Request2 ( $ uri ) ; $ request -> setConfig ( 'follow_redirects' , TRUE ) ; $ request -> setAuth ( $ this -> mail , $ this -> key ) ; return $ request ; } | Build an HTTP request object against the Acquia Cloud API . |
2,225 | protected function getApiResponseBody ( $ path ) { $ request = $ this -> createRequest ( $ path ) ; $ this -> log ( 'GET ' . $ request -> getUrl ( ) ) ; $ response = $ request -> send ( ) ; return $ response -> getBody ( ) ; } | Example of how to query the Acquia Cloud API . |
2,226 | public function main ( ) { $ this -> validate ( ) ; $ project = $ this -> getProject ( ) ; if ( $ existing_value = $ this -> project -> getProperty ( $ this -> propertyName ) ) { $ this -> log ( "Using {$this->propertyName} = '{$existing_value}' (existing value)" , Project :: MSG_INFO ) ; return ; } $ keys = array_map ... | Select menu . |
2,227 | public function lists ( $ value ) { return array_map ( function ( $ item ) use ( $ value ) { return isset ( $ item [ $ value ] ) ? $ item [ $ value ] : null ; } , $ this -> items ) ; } | Get an array with the values of a given key . |
2,228 | public function pull ( $ key , $ default = null ) { $ value = $ this -> offsetGet ( $ key ) ; $ this -> offsetUnset ( $ key ) ; return $ value ? : $ default ; } | Pulls an item from the collection . |
2,229 | public function sum ( $ callback = null ) { if ( is_null ( $ callback ) ) { return array_sum ( $ this -> items ) ; } return array_reduce ( $ this -> items , function ( $ result , $ item ) use ( $ callback ) { if ( is_string ( $ callback ) ) { return $ result += $ item -> { $ callback } ( ) ; } return $ result += $ call... | Get the sum of the collection items . |
2,230 | public function render ( $ view , $ data = [ ] , $ mergeData = [ ] ) { if ( $ this -> request ( ) -> ajax ( ) && $ this -> request ( ) -> wantsJson ( ) ) { return app ( ) -> call ( [ $ this , 'ajax' ] ) ; } if ( $ action = $ this -> request ( ) -> get ( 'action' ) and in_array ( $ action , $ this -> actions ) ) { if ( ... | Process dataTables needed render output . |
2,231 | protected function printColumns ( ) { return is_array ( $ this -> printColumns ) ? $ this -> toColumnsCollection ( $ this -> printColumns ) : $ this -> getPrintColumnsFromBuilder ( ) ; } | Get printable columns . |
2,232 | protected function mapResponseToColumns ( $ columns , $ type ) { $ transformer = new DataArrayTransformer ; return array_map ( function ( $ row ) use ( $ columns , $ type , $ transformer ) { return $ transformer -> transform ( $ row , $ columns , $ type ) ; } , $ this -> getAjaxResponseData ( ) ) ; } | Map ajax response to columns definition . |
2,233 | protected function getAjaxResponseData ( ) { $ this -> request ( ) -> merge ( [ 'length' => - 1 ] ) ; $ response = app ( ) -> call ( [ $ this , 'ajax' ] ) ; $ data = $ response -> getData ( true ) ; return $ data [ 'data' ] ; } | Get decorated data as defined in datatables ajax response . |
2,234 | public function excel ( ) { $ ext = '.' . strtolower ( $ this -> excelWriter ) ; return $ this -> buildExcelFile ( ) -> download ( $ this -> getFilename ( ) . $ ext , $ this -> excelWriter ) ; } | Export results to Excel file . |
2,235 | private function exportColumns ( ) { return is_array ( $ this -> exportColumns ) ? $ this -> toColumnsCollection ( $ this -> exportColumns ) : $ this -> getExportColumnsFromBuilder ( ) ; } | Get export columns definition . |
2,236 | private function toColumnsCollection ( array $ columns ) { $ collection = collect ( ) ; foreach ( $ columns as $ column ) { if ( isset ( $ column [ 'data' ] ) ) { $ column [ 'title' ] = $ column [ 'title' ] ?? $ column [ 'data' ] ; $ collection -> push ( new Column ( $ column ) ) ; } else { $ data = [ ] ; $ data [ 'dat... | Convert array to collection of Column class . |
2,237 | public function csv ( ) { $ ext = '.' . strtolower ( $ this -> csvWriter ) ; return $ this -> buildExcelFile ( ) -> download ( $ this -> getFilename ( ) . $ ext , $ this -> csvWriter ) ; } | Export results to CSV file . |
2,238 | public function pdf ( ) { if ( 'snappy' == config ( 'datatables-buttons.pdf_generator' , 'snappy' ) ) { return $ this -> snappyPdf ( ) ; } return $ this -> buildExcelFile ( ) -> download ( $ this -> getFilename ( ) . '.pdf' , $ this -> pdfWriter ) ; } | Export results to PDF file . |
2,239 | public function snappyPdf ( ) { $ snappy = resolve ( 'snappy.pdf.wrapper' ) ; $ options = config ( 'datatables-buttons.snappy.options' ) ; $ orientation = config ( 'datatables-buttons.snappy.orientation' ) ; $ snappy -> setOptions ( $ options ) -> setOrientation ( $ orientation ) ; return $ snappy -> loadHTML ( $ this ... | PDF version of the table using print preview blade template . |
2,240 | public function with ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { $ this -> attributes = array_merge ( $ this -> attributes , $ key ) ; } else { $ this -> attributes [ $ key ] = $ value ; } return $ this ; } | Set a custom class attribute . |
2,241 | protected function applyScopes ( $ query ) { foreach ( $ this -> scopes as $ scope ) { $ scope -> apply ( $ query ) ; } return $ query ; } | Apply query scopes . |
2,242 | protected function hasScopes ( array $ scopes , $ validateAll = false ) { $ filteredScopes = array_filter ( $ this -> scopes , function ( $ scope ) use ( $ scopes ) { return in_array ( get_class ( $ scope ) , $ scopes ) ; } ) ; return $ validateAll ? count ( $ filteredScopes ) === count ( $ scopes ) : ! empty ( $ filte... | Determine if the DataTable has scopes . |
2,243 | protected function getModel ( ) { $ name = $ this -> getNameInput ( ) ; $ rootNamespace = $ this -> laravel -> getNamespace ( ) ; $ model = $ this -> option ( 'model' ) || $ this -> option ( 'model-namespace' ) ; $ modelNamespace = $ this -> option ( 'model-namespace' ) ? $ this -> option ( 'model-namespace' ) : $ this... | Get model name to use . |
2,244 | protected function publishAssets ( ) { $ this -> publishes ( [ __DIR__ . '/config/config.php' => config_path ( 'datatables-buttons.php' ) , ] , 'datatables-buttons' ) ; $ this -> publishes ( [ __DIR__ . '/resources/assets/buttons.server-side.js' => public_path ( 'vendor/datatables/buttons.server-side.js' ) , ] , 'datat... | Publish datatables assets . |
2,245 | public function transform ( array $ row , $ columns , $ type = 'printable' ) { if ( $ columns instanceof Collection ) { return $ this -> buildColumnByCollection ( $ row , $ columns , $ type ) ; } return array_only ( $ row , $ columns ) ; } | Transform row data by columns definition . |
2,246 | protected function buildColumnByCollection ( array $ row , Collection $ columns , $ type = 'printable' ) { $ results = [ ] ; foreach ( $ columns -> all ( ) as $ column ) { if ( $ column [ $ type ] ) { $ title = $ column [ 'title' ] ; $ data = array_get ( $ row , $ column [ 'data' ] ) ; if ( $ type == 'exportable' ) { $... | Transform row column by collection . |
2,247 | protected function decodeContent ( $ data ) { try { $ decoded = html_entity_decode ( strip_tags ( $ data ) , ENT_QUOTES , 'UTF-8' ) ; return str_replace ( "\xc2\xa0" , ' ' , $ decoded ) ; } catch ( \ Exception $ e ) { return $ data ; } } | Decode content to a readable text value . |
2,248 | public function createActivity ( ) { $ activity = [ ] ; $ activity [ 'actor' ] = $ this -> activityActor ( ) ; $ activity [ 'verb' ] = $ this -> activityVerb ( ) ; $ activity [ 'object' ] = $ this -> activityObject ( ) ; $ activity [ 'foreign_id' ] = $ this -> activityForeignId ( ) ; $ activity [ 'time' ] = $ this -> a... | The activity data for this instance |
2,249 | public function isAuthorizedTo ( Session $ session , ActionMessageInterface $ actionMsg ) { $ action = $ actionMsg -> getActionName ( ) ; $ uri = $ actionMsg -> getUri ( ) ; $ authenticationDetails = $ session -> getAuthenticationDetails ( ) ; if ( $ authenticationDetails -> hasAuthRole ( 'admin' ) ) { return true ; } ... | Check to see if an action is authorized on a specific uri given the context of the session attempting the action |
2,250 | public function publishState ( Subscription $ subscription ) { $ subscription -> pauseForState ( ) ; $ sessionId = $ subscription -> getSession ( ) -> getSessionId ( ) ; $ this -> clientSession -> call ( $ this -> getProcedureName ( ) , [ $ subscription -> getUri ( ) , $ sessionId , $ subscription -> getOptions ( ) , $... | Gets and published the topics state to this subscription |
2,251 | public function getFeatures ( ) { $ features = new \ stdClass ( ) ; $ features -> subscriber_blackwhite_listing = true ; $ features -> publisher_exclusion = true ; $ features -> subscriber_metaevents = true ; return $ features ; } | Return supported features |
2,252 | protected function processSubscribe ( Session $ session , SubscribeMessage $ msg ) { $ matcher = $ this -> getMatcherForMatchType ( $ msg -> getMatchType ( ) ) ; if ( $ matcher === false ) { Logger :: alert ( $ this , "no matching match type for \"" . $ msg -> getMatchType ( ) . "\" for URI \"" . $ msg -> getUri ( ) . ... | Process subscribe message |
2,253 | protected function processPublish ( Session $ session , PublishMessage $ msg ) { if ( $ msg -> getPublicationId ( ) === null ) { $ msg -> setPublicationId ( Utils :: getUniqueId ( ) ) ; } foreach ( $ this -> subscriptionGroups as $ subscriptionGroup ) { $ subscriptionGroup -> processPublish ( $ session , $ msg ) ; } if... | Process publish message |
2,254 | protected function processUnsubscribe ( Session $ session , UnsubscribeMessage $ msg ) { $ subscription = false ; foreach ( $ this -> subscriptionGroups as $ subscriptionGroup ) { $ result = $ subscriptionGroup -> processUnsubscribe ( $ session , $ msg ) ; if ( $ result !== false ) { $ subscription = $ result ; } } if ... | Process Unsubscribe message |
2,255 | public function processYield ( Session $ session , YieldMessage $ msg ) { $ keepIndex = true ; $ details = new \ stdClass ( ) ; $ yieldOptions = $ msg -> getOptions ( ) ; if ( is_object ( $ yieldOptions ) && isset ( $ yieldOptions -> progress ) && $ yieldOptions -> progress ) { if ( $ this -> isProgressive ( ) ) { $ de... | Process Yield message |
2,256 | public function processCancel ( Session $ session , CancelMessage $ msg ) { if ( $ this -> getCallerSession ( ) !== $ session ) { Logger :: warning ( $ this , 'session attempted to cancel call they did not own.' ) ; return false ; } if ( $ this -> getCalleeSession ( ) === null ) { $ errorMsg = ErrorMessage :: createErr... | processCancel processes cancel message from the caller . Return true if the Call should be removed from active calls |
2,257 | public function getRegistrationById ( $ registrationId ) { foreach ( $ this -> registrations as $ registration ) { if ( $ registration -> getId ( ) === $ registrationId ) { return $ registration ; } } return false ; } | Get registration by ID |
2,258 | public function processQueue ( ) { if ( ! $ this -> getAllowMultipleRegistrations ( ) ) { throw new \ Exception ( 'Queuing only allowed when there are multiple registrations' ) ; } while ( $ this -> callQueue -> count ( ) > 0 ) { $ registration = NULL ; if ( strcasecmp ( $ this -> getInvokeType ( ) , Registration :: FI... | Process the Queue |
2,259 | public function removeCall ( Call $ call ) { $ newQueue = new \ SplQueue ( ) ; while ( ! $ this -> callQueue -> isEmpty ( ) ) { $ c = $ this -> callQueue -> dequeue ( ) ; if ( $ c === $ call ) continue ; $ newQueue -> enqueue ( $ c ) ; } $ this -> callQueue = $ newQueue ; $ registration = $ call -> getRegistration ( ) ... | Remove all references to Call to it can be GCed |
2,260 | public function leave ( Session $ session ) { foreach ( $ this -> registrations as $ i => $ registration ) { if ( $ registration -> getSession ( ) === $ session ) { $ registration -> errorAllPendingCalls ( ) ; array_splice ( $ this -> registrations , $ i , 1 ) ; } } } | process session leave |
2,261 | public function onSessionLeave ( $ args , $ kwArgs , $ options ) { if ( ! empty ( $ args [ 0 ] [ 'session' ] ) ) { foreach ( $ this -> _sessions as $ key => $ details ) { if ( $ args [ 0 ] [ 'session' ] == $ details [ 'session' ] ) { echo "Session {$details['session']} leaved\n" ; unset ( $ this -> _sessions [ $ key ] ... | Handle on session leaved |
2,262 | public function getRealm ( $ realmName ) { if ( ! is_scalar ( $ realmName ) ) { throw new \ InvalidArgumentException ( 'Non-string value given for realm name' ) ; } if ( ! array_key_exists ( $ realmName , $ this -> realms ) ) { if ( $ this -> getAllowRealmAutocreate ( ) ) { Logger :: debug ( $ this , 'Creating new real... | Get Realm by realm name |
2,263 | public function addRealm ( Realm $ realm ) { $ realmName = $ realm -> getRealmName ( ) ; if ( ! static :: validRealmName ( $ realm -> getRealmName ( ) ) ) { throw new InvalidRealmNameException ; } if ( array_key_exists ( $ realm -> getRealmName ( ) , $ this -> realms ) ) { throw new \ Exception ( 'There is already a re... | Add new realm |
2,264 | public function initModule ( RouterInterface $ router , LoopInterface $ loop ) { $ this -> router = $ router ; $ this -> setLoop ( $ loop ) ; $ this -> router -> addInternalClient ( $ this ) ; } | Called by the router when it is added |
2,265 | protected function removeCall ( Call $ call ) { $ call -> getProcedure ( ) -> removeCall ( $ call ) ; unset ( $ this -> callInvocationIndex [ $ call -> getInvocationRequestId ( ) ] ) ; unset ( $ this -> callRequestIndex [ $ call -> getCallMessage ( ) -> getRequestId ( ) ] ) ; if ( $ call -> getCancelMessage ( ) ) { uns... | This removes all references to calls so they can be GCed |
2,266 | public function getCallByRequestId ( $ requestId ) { $ call = isset ( $ this -> callRequestIndex [ $ requestId ] ) ? $ this -> callRequestIndex [ $ requestId ] : false ; return $ call ; } | Get Call by requestID |
2,267 | public function handlesMessage ( Message $ msg ) { $ handledMsgCodes = [ Message :: MSG_CALL , Message :: MSG_CANCEL , Message :: MSG_REGISTER , Message :: MSG_UNREGISTER , Message :: MSG_YIELD , Message :: MSG_INTERRUPT ] ; if ( in_array ( $ msg -> getMsgCode ( ) , $ handledMsgCodes ) ) { return true ; } elseif ( $ ms... | Returns true if this role handles this message . |
2,268 | public function leave ( Session $ session ) { foreach ( $ this -> procedures as $ procedure ) { $ procedure -> leave ( $ session ) ; } foreach ( $ this -> callInvocationIndex as $ call ) { if ( $ session -> getSessionId ( ) === $ call -> getCallerSession ( ) -> getSessionId ( ) ) { $ cancelMsg = new CancelMessage ( $ c... | process leave session |
2,269 | public function managerGetRegistrations ( ) { $ theRegistrations = [ ] ; foreach ( $ this -> procedures as $ procedure ) { foreach ( $ procedure -> getRegistrations ( ) as $ registration ) { $ theRegistrations [ ] = [ 'id' => $ registration -> getId ( ) , 'name' => $ registration -> getProcedureName ( ) , 'session' => ... | Get list registrations |
2,270 | public function managerGetSessions ( ) { $ theSessions = [ ] ; foreach ( $ this -> sessions as $ session ) { $ sessionRealm = null ; if ( $ session -> getRealm ( ) !== null ) { $ sessionRealm = $ session -> getRealm ( ) -> getRealmName ( ) ; } if ( $ session -> getAuthenticationDetails ( ) !== null ) { $ authDetails = ... | Get list sessions |
2,271 | public function leave ( Session $ session ) { Logger :: debug ( $ this , "Leaving realm {$session->getRealm()->getRealmName()}" ) ; $ key = array_search ( $ session , $ this -> sessions , true ) ; if ( $ key !== false ) { array_splice ( $ this -> sessions , $ key , 1 ) ; } } | Process on session leave |
2,272 | public function initModule ( RouterInterface $ router , LoopInterface $ loop ) { parent :: initModule ( $ router , $ loop ) ; $ this -> routerRealm = $ router -> getRealmManager ( ) -> getRealm ( $ this -> getRealm ( ) ) ; $ this -> broker = $ this -> routerRealm -> getBroker ( ) ; $ this -> broker -> setStateHandlerRe... | Gets called when the module is initialized in the router |
2,273 | private function setupStateHandlerRegistration ( SubscriptionGroup $ subscriptionGroup ) { foreach ( $ this -> stateHandlerRegistrations as $ stateHandlerRegistration ) { if ( $ stateHandlerRegistration -> handlesStateFor ( $ subscriptionGroup ) ) { $ this -> stateHandlerMap -> attach ( $ subscriptionGroup , $ stateHan... | Called when we need to setup a registration If there is a registration that works - then we set the handler Otherwise we set it to null |
2,274 | public function onSessionStart ( $ session , $ transport ) { $ session -> register ( "thruway.auth.{$this->getMethodName()}.onhello" , [ $ this , 'processHello' ] , [ 'replace_orphaned_session' => 'yes' ] ) -> then ( function ( ) use ( $ session ) { $ session -> register ( "thruway.auth.{$this->getMethodName()}.onauthe... | Handles session start |
2,275 | public function preProcessAuthenticate ( array $ args ) { $ args = $ args [ 0 ] ; $ signature = isset ( $ args -> signature ) ? $ args -> signature : null ; $ extra = isset ( $ args -> extra ) ? $ args -> extra : null ; if ( ! $ signature ) { return [ 'ERROR' ] ; } return $ this -> processAuthenticate ( $ signature , $... | Pre process AuthenticateMessage Extract and validate arguments |
2,276 | function add ( $ userName , $ password , $ salt = null ) { if ( $ salt !== null ) { $ key = \ Thruway \ Common \ Utils :: getDerivedKey ( $ password , $ salt ) ; } else { $ key = $ password ; } $ this -> users [ $ userName ] = [ "authid" => $ userName , "key" => $ key , "salt" => $ salt ] ; } | Add new user |
2,277 | private function sendEventMessage ( Session $ session , PublishMessage $ msg , Subscription $ subscription ) { $ sessionId = $ subscription -> getSession ( ) -> getSessionId ( ) ; $ authroles = [ ] ; $ authid = '' ; $ authenticationDetails = $ subscription -> getSession ( ) -> getAuthenticationDetails ( ) ; if ( $ auth... | Send an Event Message for each subscription |
2,278 | public static function createSubscriptionFromSubscribeMessage ( Session $ session , SubscribeMessage $ msg ) { $ options = $ msg -> getOptions ( ) ; $ subscription = new Subscription ( $ msg -> getTopicName ( ) , $ session , $ options ) ; if ( isset ( $ options -> disclose_publisher ) && $ options -> disclose_publisher... | Create Subscription from SubscribeMessage |
2,279 | public function onHttpRequest ( \ React \ Http \ Request $ request , $ response ) { if ( $ request -> getPath ( ) !== "/auth/github/callback" ) { $ response -> writeHead ( 404 , [ 'Content-Type' => 'text/plain' ] ) ; $ response -> end ( "Not Found" ) ; return ; } $ query = $ request -> getQuery ( ) ; if ( ! isset ( $ q... | Handle process on http request |
2,280 | private function getAccessToken ( $ code ) { $ data = [ "client_id" => $ this -> clientId , "client_secret" => $ this -> clientSecret , "code" => $ code ] ; $ data_string = json_encode ( $ data ) ; $ ch = curl_init ( 'https://github.com/login/oauth/access_token' ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , "POST" )... | Get access token from code |
2,281 | private function getEmails ( $ accessToken ) { $ ch = curl_init ( "https://api.github.com/user/emails?access_token={$accessToken}" ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , "GET" ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , [ 'Content-Type: application/json... | Get list email from accesstokens |
2,282 | private function getChallengeFromExtra ( $ extra ) { return ( is_object ( $ extra ) && isset ( $ extra -> challenge_details ) && is_object ( $ extra -> challenge_details ) && isset ( $ extra -> challenge_details -> challenge ) ) ? json_decode ( $ extra -> challenge_details -> challenge ) : false ; } | Gets the Challenge Message from the extra object |
2,283 | public function onClose ( TransportInterface $ transport ) { Logger :: debug ( $ this , 'onClose from ' . json_encode ( $ transport -> getTransportDetails ( ) ) ) ; $ this -> sessions -> detach ( $ transport ) ; } | Handle close transport |
2,284 | public function getSessionBySessionId ( $ sessionId ) { if ( ! is_scalar ( $ sessionId ) ) { return false ; } return isset ( $ this -> sessions [ $ sessionId ] ) ? $ this -> sessions [ $ sessionId ] : false ; } | Get session by session ID |
2,285 | public function managerGetRealms ( ) { $ theRealms = [ ] ; foreach ( $ this -> realmManager -> getRealms ( ) as $ realm ) { $ theRealms [ ] = [ 'name' => $ realm -> getRealmName ( ) ] ; } return [ $ theRealms ] ; } | Get list realms |
2,286 | public function registerModule ( RouterModuleInterface $ module ) { $ module -> initModule ( $ this , $ this -> getLoop ( ) ) ; $ this -> eventDispatcher -> addSubscriber ( $ module ) ; } | Registers a RouterModule |
2,287 | public static function createRegistrationFromRegisterMessage ( Session $ session , RegisterMessage $ msg ) { $ registration = new self ( $ session , $ msg -> getProcedureName ( ) ) ; $ options = $ msg -> getOptions ( ) ; if ( isset ( $ options -> disclose_caller ) && $ options -> disclose_caller === true ) { $ registra... | Create Registration from RegisterMessage |
2,288 | public function errorAllPendingCalls ( ) { foreach ( $ this -> calls as $ call ) { $ call -> getCallerSession ( ) -> sendMessage ( ErrorMessage :: createErrorMessageFromMessage ( $ call -> getCallMessage ( ) , 'wamp.error.canceled' ) ) ; } } | This will send error messages on all pending calls This is used when a session disconnects before completing a call |
2,289 | public function getStatistics ( ) { return [ 'currentCallCount' => count ( $ this -> calls ) , 'registeredAt' => $ this -> registeredAt , 'invocationCount' => $ this -> invocationCount , 'invocationAverageTime' => $ this -> invocationAverageTime , 'busyTime' => $ this -> busyTime , 'busyStart' => $ this -> busyStart , ... | Get registration statistics |
2,290 | public function onClose ( ) { if ( $ this -> realm !== null ) { if ( $ this -> isAuthenticated ( ) ) { $ this -> getRealm ( ) -> publishMeta ( 'wamp.metaevent.session.on_leave' , [ $ this -> getMetaInfo ( ) ] ) ; } $ this -> dispatcher -> dispatch ( 'LeaveRealm' , new LeaveRealmEvent ( $ this -> realm , $ this ) ) ; $ ... | Handle close session |
2,291 | public function setAuthenticated ( $ authenticated ) { if ( $ authenticated && ! $ this -> authenticated ) { $ this -> getRealm ( ) -> publishMeta ( 'wamp.metaevent.session.on_join' , [ $ this -> getMetaInfo ( ) ] ) ; } parent :: setAuthenticated ( $ authenticated ) ; } | Set authenticated state |
2,292 | public function getMetaInfo ( ) { if ( $ this -> getAuthenticationDetails ( ) instanceof AuthenticationDetails ) { $ authId = $ this -> getAuthenticationDetails ( ) -> getAuthId ( ) ; $ authMethod = $ this -> getAuthenticationDetails ( ) -> getAuthMethod ( ) ; $ authRole = $ this -> getAuthenticationDetails ( ) -> getA... | Get meta info |
2,293 | private function onHelloAuthHandler ( $ authMethod , $ authMethodInfo , Realm $ realm , Session $ session , HelloMessage $ msg ) { $ authDetails = new AuthenticationDetails ( ) ; $ authDetails -> setAuthMethod ( $ authMethod ) ; $ helloDetails = $ msg -> getDetails ( ) ; if ( isset ( $ helloDetails -> authid ) ) { $ au... | Call the RPC URI that has been registered to handle Authentication Hello Messages |
2,294 | public function handleAuthenticateMessage ( Realm $ realm , Session $ session , AuthenticateMessage $ msg ) { if ( $ session -> getAuthenticationDetails ( ) === null ) { throw new \ Exception ( 'Authenticate with no previous auth details' ) ; } $ authMethod = $ session -> getAuthenticationDetails ( ) -> getAuthMethod (... | Handle Authenticate message |
2,295 | private function onAuthenticateHandler ( $ authMethod , $ authMethodInfo , Realm $ realm , Session $ session , AuthenticateMessage $ msg ) { $ onAuthenticateSuccess = function ( $ res ) use ( $ realm , $ session ) { if ( count ( $ res ) < 1 ) { $ session -> abort ( new \ stdClass ( ) , 'thruway.error.authentication_fai... | Call the handler that was registered to handle the Authenticate Message |
2,296 | private function realmHasAuthProvider ( $ realmName ) { foreach ( $ this -> authMethods as $ authMethod ) { foreach ( $ authMethod [ 'auth_realms' ] as $ authRealm ) { if ( $ authRealm === "*" || $ authRealm === $ realmName ) { return true ; } } } return false ; } | Checks to see if a realm has a registered auth provider |
2,297 | public function onSessionClose ( Session $ session ) { if ( $ session -> getRealm ( ) && $ session -> getRealm ( ) -> getRealmName ( ) === 'thruway.auth' ) { $ sessionId = $ session -> getSessionId ( ) ; foreach ( $ this -> authMethods as $ methodName => $ method ) { if ( isset ( $ method [ 'session_id' ] ) && $ method... | This allows the AuthenticationManager to clean out auth methods that were registered by sessions that are dieing . Otherwise the method could be hijacked by another client in the thruway . auth realm . |
2,298 | private function abortSessionUsingResponse ( Session $ session , $ response ) { if ( ! isset ( $ response [ 0 ] ) || $ response [ 0 ] !== 'FAILURE' ) { return false ; } if ( ! isset ( $ response [ 1 ] ) || ! is_object ( $ response [ 1 ] ) ) { $ session -> abort ( new \ stdClass ( ) , 'thruway.error.authentication_failu... | Send an abort message to the session if the Authenticator sent a FAILURE response Returns true if the abort was sent false otherwise |
2,299 | private function execFollow ( ) { $ mr = 5 ; $ body = null ; if ( ini_get ( "open_basedir" ) == "" && ini_get ( "safe_mode" == "Off" ) ) { $ this -> setOptions ( array ( CURLOPT_FOLLOWLOCATION => $ mr > 0 , CURLOPT_MAXREDIRS => $ mr ) ) ; } else { $ this -> setOption ( CURLOPT_FOLLOWLOCATION , false ) ; if ( $ mr > 0 )... | Function which acts as a replacement for curl s default FOLLOW_LOCATION option since that gives errors when combining it with open basedir . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.