idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
51,100 | private function getAcceptedRatePlans ( array $ query_params = [ ] ) : array { $ entities = [ ] ; foreach ( $ this -> getRawList ( $ this -> getAcceptedRatePlansEndpoint ( ) -> withQuery ( http_build_query ( $ query_params ) ) ) as $ item ) { $ tmp = $ this -> getEntitySerializer ( ) -> denormalize ( $ item , AcceptedR... | Helper function for listing accepted rate plans . |
51,101 | protected function authClient ( ) : ClientInterface { return new Client ( new BasicAuth ( $ this -> clientId , $ this -> clientSecret ) , $ this -> auth_server ) ; } | Returns a pre - configured client for authorization API calls . |
51,102 | private function getAccessToken ( ) : void { if ( $ this -> tokenStorage -> getRefreshToken ( ) ) { $ body = [ 'grant_type' => 'refresh_token' , 'refresh_token' => $ this -> tokenStorage -> getRefreshToken ( ) , ] ; } else { $ body = [ 'grant_type' => 'password' , 'username' => $ this -> username , 'password' => $ this... | Retrieves access token and saves it to the token storage . |
51,103 | protected function getEntityAttributesUri ( string $ entityId ) : UriInterface { $ uri = $ this -> getEntityEndpointUri ( $ entityId ) -> withPath ( $ this -> getEntityEndpointUri ( $ entityId ) . '/attributes' ) ; return $ uri ; } | Returns the base URI of an entity type s attributes . |
51,104 | protected function getEntityAttributeUri ( string $ entityId , string $ name ) : UriInterface { $ uri = $ this -> getEntityAttributesUri ( $ entityId ) -> withPath ( $ this -> getEntityAttributesUri ( $ entityId ) . '/' . $ name ) ; return $ uri ; } | Returns an URI to an entity s attribute . |
51,105 | public function addSuccess ( RequestInterface $ request , ResponseInterface $ response ) : void { $ this -> lastRequest = $ request ; $ this -> lastResponse = $ response ; $ this -> success = true ; } | Record a successful call . |
51,106 | public function addFailure ( RequestInterface $ request , Exception $ exception ) : void { $ this -> lastRequest = $ request ; $ this -> lastException = $ exception ; } | Record a failed call . |
51,107 | public function getOptimisedMetrics ( StatsQueryInterface $ query ) : array { $ response = $ this -> getMetrics ( $ query , 'js' ) ; if ( empty ( $ response [ 'stats' ] ) ) { return $ response ; } if ( null !== $ query -> getTimeUnit ( ) ) { $ originalTimeUnits = $ response [ 'TimeUnit' ] ; $ response [ 'TimeUnit' ] = ... | Gets API message count . |
51,108 | public function getOptimizedMetricsByDimensions ( array $ dimensions , StatsQueryInterface $ query ) : array { $ response = $ this -> getMetricsByDimensions ( $ dimensions , $ query , 'js' ) ; if ( empty ( $ response [ 'stats' ] ) ) { return $ response ; } if ( null !== $ query -> getTimeUnit ( ) ) { $ originalTimeUnit... | Gets optimized metrics organized by dimensions . |
51,109 | private function fillGapsInTimeUnitsData ( Period $ period , string $ timeUnit , bool $ tsAscending ) { if ( in_array ( $ timeUnit , [ 'decade' , 'century' , 'millennium' ] ) ) { throw new \ InvalidArgumentException ( "The {$timeUnit} time unit is not supported by the https://github.com/fightbulc/moment.php library." )... | Fills the gaps between returned time units in the response of Apigee Edge . |
51,110 | private function fillGapsInMetricsData ( bool $ tsAscending , array $ allTimeUnits , array $ originalTimeUnits , array & $ metricsData ) : void { $ zeroArray = array_fill_keys ( $ allTimeUnits , 0 ) ; foreach ( $ metricsData as $ key => $ metric ) { $ metricsData [ $ key ] [ 'values' ] = array_combine ( $ originalTimeU... | Fills the gaps between returned analytics numbers in the response of Apigee Edge . |
51,111 | public function setupRecurringPayments ( string $ currencyCode , string $ paymentProviderId , float $ replenishAmount , float $ recurringAmount ) : BalanceInterface { $ response = $ this -> client -> post ( $ this -> getBaseEndpointUri ( ) -> withPath ( "{$this->getBaseEndpointUri()->getPath()}/recurring-setup" ) -> wi... | Enables and modifies recurring payment settings . |
51,112 | public function disableRecurringPayments ( string $ currencyCode , string $ paymentProviderId ) : BalanceInterface { $ response = $ this -> client -> post ( $ this -> getBaseEndpointUri ( ) -> withPath ( "{$this->getBaseEndpointUri()->getPath()}/recurring-setup" ) -> withQuery ( http_build_query ( [ 'supportedCurrencyI... | Deactivate recurring payments . |
51,113 | private function listPrepaidBalances ( \ DateTimeImmutable $ billingMonth , ? string $ currencyCode = null ) : array { $ query_params = [ 'billingMonth' => strtoupper ( $ billingMonth -> format ( 'F' ) ) , 'billingYear' => $ billingMonth -> format ( 'Y' ) , ] ; if ( null !== $ currencyCode ) { $ query_params [ 'support... | Helper function which returns prepaid balances .. |
51,114 | protected function listEntities ( PagerInterface $ pager = null , array $ query_params = [ ] , string $ key_provider = 'id' ) : array { $ organization = $ this -> getOrganizationController ( ) -> load ( $ this -> getOrganisationName ( ) ) ; $ isCpsEnabled = $ organization -> getPropertyValue ( 'features.isCpsEnabled' )... | Loads paginated list of entities from Apigee Edge . |
51,115 | protected function listEntityIds ( PagerInterface $ pager = null , array $ query_params = [ ] ) : array { $ organization = $ this -> getOrganizationController ( ) -> load ( $ this -> getOrganisationName ( ) ) ; $ isCpsEnabled = $ organization -> getPropertyValue ( 'features.isCpsEnabled' ) ; if ( $ isCpsEnabled ) { ret... | Loads entity ids from Apigee Edge . |
51,116 | private function listEntitiesWithCps ( PagerInterface $ pager = null , array $ query_params = [ ] , string $ key_provider = 'id' ) : array { $ query_params = [ 'expand' => 'true' , ] + $ query_params ; if ( $ pager ) { $ responseArray = $ this -> getResultsInRange ( $ pager , $ query_params ) ; $ responseArray = reset ... | Real paginated entity listing on organization with CPS support . |
51,117 | private function listEntitiesWithoutCps ( PagerInterface $ pager = null , array $ query_params = [ ] , string $ key_provider = 'id' ) : array { $ query_params = [ 'expand' => 'true' , ] + $ query_params ; $ uri = $ this -> getBaseEndpointUri ( ) -> withQuery ( http_build_query ( $ query_params ) ) ; $ response = $ this... | Simulates paginated entity listing on organization without CPS support . |
51,118 | private function getResultsInRange ( PagerInterface $ pager , array $ query_params ) : array { $ query_params [ 'startKey' ] = $ pager -> getStartKey ( ) ; if ( $ pager -> getLimit ( ) > 0 ) { $ query_params [ 'count' ] = $ pager -> getLimit ( ) ; } $ uri = $ this -> getBaseEndpointUri ( ) -> withQuery ( http_build_que... | Gets entities and entity ids in a provided range from Apigee Edge . |
51,119 | private function listEntityIdsWithCps ( PagerInterface $ pager = null , array $ query_params = [ ] ) : array { $ query_params = [ 'expand' => 'false' , ] + $ query_params ; if ( $ pager ) { return $ this -> getResultsInRange ( $ pager , $ query_params ) ; } else { $ ids = $ this -> getResultsInRange ( $ this -> createP... | Real paginated entity id listing on organization with CPS support . |
51,120 | private function listEntityIdsWithoutCps ( PagerInterface $ pager = null , array $ query_params = [ ] ) : array { $ query_params = [ 'expand' => 'false' , ] + $ query_params ; $ uri = $ this -> getBaseEndpointUri ( ) -> withQuery ( http_build_query ( $ query_params ) ) ; $ response = $ this -> getClient ( ) -> get ( $ ... | Simulates paginated entity id listing on organization without CPS . |
51,121 | private function simulateCpsPagination ( PagerInterface $ pager , array $ result , array $ array_search_haystack = null ) : array { $ array_search_haystack = $ array_search_haystack ?? $ result ; $ start_key = $ pager -> getStartKey ( ) ?? reset ( $ array_search_haystack ) ; $ offset = array_search ( $ start_key , $ ar... | Simulates paginated response on an organization without CPS . |
51,122 | private function decodeResponse ( ResponseInterface $ response , RequestInterface $ request ) { if ( $ response -> getStatusCode ( ) >= 400 && $ response -> getStatusCode ( ) < 500 ) { if ( 401 === $ response -> getStatusCode ( ) ) { if ( 0 === strpos ( $ request -> getHeaderLine ( 'Authorization' ) , 'Bearer' ) ) { th... | Throws one our of our exceptions if the API response code is higher than 399 . |
51,123 | protected function getOpeningTagPos ( ) { $ startPositionInBlob = false ; if ( preg_match ( "/<" . preg_quote ( $ this -> options [ "uniqueNode" ] ) . "(>| )/" , $ this -> workingBlob , $ matches , PREG_OFFSET_CAPTURE ) === 1 ) { $ startPositionInBlob = $ matches [ 0 ] [ 1 ] ; } if ( $ startPositionInBlob === false ) {... | Search the blob for our unique node s opening tag |
51,124 | protected function getClosingTagPos ( ) { $ endPositionInBlob = strpos ( $ this -> workingBlob , "</" . $ this -> options [ "uniqueNode" ] . ">" ) ; if ( $ endPositionInBlob === false ) { if ( isset ( $ this -> options [ "checkShortClosing" ] ) && $ this -> options [ "checkShortClosing" ] === true ) { $ endPositionInBl... | Search the blob for our unique node s closing tag |
51,125 | protected function prepareChunk ( StreamInterface $ stream ) { if ( $ this -> hasSearchedUntilPos > - 1 && $ this -> hasSearchedUntilPos < ( strlen ( $ this -> workingBlob ) - 1 ) ) { return true ; } $ chunk = $ stream -> getChunk ( ) ; if ( $ chunk === false ) { if ( $ this -> hasSearchedUntilPos === - 1 && strlen ( $... | Decides whether we re to fetch more chunks from the stream or keep working with what we have . |
51,126 | protected function shave ( ) { preg_match ( "/<[^>]+>/" , $ this -> chunk , $ matches , PREG_OFFSET_CAPTURE ) ; if ( isset ( $ matches [ 0 ] , $ matches [ 0 ] [ 0 ] , $ matches [ 0 ] [ 1 ] ) ) { list ( $ captured , $ offset ) = $ matches [ 0 ] ; if ( $ this -> options [ "expectGT" ] ) { foreach ( $ this -> options [ "t... | Shaves off the next element from the chunk |
51,127 | protected function getEdges ( $ element ) { foreach ( $ this -> options [ "tags" ] as $ tag ) { list ( $ opening , $ closing , $ depth ) = $ tag ; if ( substr ( $ element , 0 , strlen ( $ opening ) ) === $ opening && substr ( $ element , - 1 * strlen ( $ closing ) ) === $ closing ) { return $ tag ; } } } | Extract XML compatible tag head and tail |
51,128 | protected function prepareChunk ( StreamInterface $ stream ) { if ( ! $ this -> firstRun && is_null ( $ this -> shaved ) ) { $ this -> shaved = "" ; return true ; } else if ( is_null ( $ this -> shaved ) ) { $ this -> shaved = "" ; } $ newChunk = $ stream -> getChunk ( ) ; if ( $ newChunk !== false ) { $ this -> chunk ... | The shave method must be able to request more data even though there isn t any more to fetch from the stream this method wraps the getChunk call so that it returns true as long as there is XML data left |
51,129 | public static function createStringWalkerParser ( $ file , $ options = array ( ) ) { $ stream = new Stream \ File ( $ file , 16384 ) ; $ parser = new Parser \ StringWalker ( $ options ) ; return new XmlStringStreamer ( $ parser , $ stream ) ; } | Convenience method for creating a StringWalker parser with a File stream |
51,130 | public static function createUniqueNodeParser ( $ file , $ options = array ( ) ) { $ stream = new Stream \ File ( $ file , 16384 ) ; $ parser = new Parser \ UniqueNode ( $ options ) ; return new XmlStringStreamer ( $ parser , $ stream ) ; } | Convenience method for creating a UniqueNode parser with a File stream |
51,131 | public static function bootHasImageUploads ( ) { static :: saved ( function ( $ model ) { if ( ! $ model -> disableAutoUpload ) { $ model -> autoUpload ( ) ; } } ) ; static :: deleted ( function ( $ model ) { $ model -> autoDeleteImage ( ) ; } ) ; } | Boot up the trait |
51,132 | public function imageUrl ( $ field = null ) { $ this -> uploadFieldName = $ this -> getUploadFieldName ( $ field ) ; $ this -> uploadFieldOptions = $ this -> getUploadFieldOptions ( $ this -> uploadFieldName ) ; $ attributeValue = $ this -> getOriginal ( $ this -> uploadFieldName ) ; $ placeholderImage = array_get ( $ ... | Get absolute url for a field |
51,133 | public function imageTag ( $ field = null , $ attributes = '' ) { if ( ! $ this -> hasImageField ( $ field ) || $ this -> hasFileField ( $ field ) ) { return '' ; } try { return '<img src="' . $ this -> imageUrl ( $ field ) . '" ' . $ attributes . ' />' ; } catch ( \ Exception $ exception ) { } } | Get html image tag for a field if image present |
51,134 | public function uploadImage ( $ imageFile , $ field = null ) { $ this -> uploadFieldName = $ this -> getUploadFieldName ( $ field ) ; $ this -> uploadFieldOptions = $ this -> getUploadFieldOptions ( $ this -> uploadFieldName ) ; $ this -> validateImage ( $ imageFile , $ this -> uploadFieldName , $ this -> uploadFieldOp... | Upload and resize image |
51,135 | public function resizeImage ( $ imageFile , $ imageFieldOptions ) { $ image = Image :: make ( $ imageFile ) ; if ( ! $ this -> needResizing ( $ imageFieldOptions ) ) { return $ image ; } $ width = array_get ( $ imageFieldOptions , 'width' ) ; $ height = array_get ( $ imageFieldOptions , 'height' ) ; $ cropHeight = empt... | Resize image based on options |
51,136 | public function setImagesField ( $ fieldsOptions ) { if ( isset ( static :: $ imageFields ) ) { static :: $ imageFields = array_merge ( $ this -> getDefinedUploadFields ( ) , $ fieldsOptions ) ; } else { $ this -> imagesFields = $ fieldsOptions ; } return $ this ; } | Setter for model image fields |
51,137 | public function setFilesField ( $ fieldsOptions ) { if ( isset ( static :: $ fileFields ) ) { static :: $ fileFields = array_merge ( $ this -> getDefinedUploadFields ( ) , $ fieldsOptions ) ; } else { $ this -> filesFields = $ fieldsOptions ; } return $ this ; } | Setter for model file fields |
51,138 | public function getUploadFieldOptions ( $ field = null ) { if ( is_null ( $ field ) ) { $ imagesFields = $ this -> getDefinedUploadFields ( ) ; if ( ! $ imagesFields ) { throw new InvalidUploadFieldException ( 'No upload fields are defined in $imageFields/$fileFields array on model.' ) ; } $ fieldKey = array_first ( ar... | Get upload field options |
51,139 | public function getDefinedUploadFields ( ) { $ fields = isset ( static :: $ imageFields ) ? static :: $ imageFields : $ this -> imagesFields ; return array_merge ( $ this -> getDefinedFileFields ( ) , $ fields ) ; } | Get all the image and file fields defined on model |
51,140 | public function getUploadFieldName ( $ field = null ) { if ( ! is_null ( $ field ) ) { return $ field ; } $ imagesFields = $ this -> getDefinedUploadFields ( ) ; $ fieldKey = array_first ( array_keys ( $ imagesFields ) ) ; return is_int ( $ fieldKey ) ? $ imagesFields [ $ fieldKey ] : $ fieldKey ; } | Get the upload field name |
51,141 | private function hasUploadField ( $ field , $ definedField ) { if ( array_has ( $ definedField , $ field ) ) { return true ; } $ found = false ; foreach ( $ definedField as $ key => $ val ) { $ found = ( is_numeric ( $ key ) && $ val === $ field ) ; if ( $ found ) { break ; } } return $ found ; } | Check is upload field is defined |
51,142 | private function deleteUploadedFile ( $ filePath ) { if ( $ this -> getStorageDisk ( ) -> exists ( $ filePath ) ) { $ this -> getStorageDisk ( ) -> delete ( $ filePath ) ; } } | Delete a file from disk |
51,143 | protected function getImageUploadPath ( ) { if ( $ pathInOption = array_get ( $ this -> uploadFieldOptions , 'path' ) ) { return $ pathInOption ; } return property_exists ( $ this , 'imagesUploadPath' ) ? trim ( $ this -> imagesUploadPath , '/' ) : trim ( config ( 'imageup.upload_directory' , 'uploads' ) , '/' ) ; } | Get image upload path |
51,144 | protected function getFileUploadPath ( $ file ) { $ pathOverrideMethod = camel_case ( strtolower ( $ this -> uploadFieldName ) . 'UploadFilePath' ) ; if ( method_exists ( $ this , $ pathOverrideMethod ) ) { return $ this -> getImageUploadPath ( ) . '/' . $ this -> $ pathOverrideMethod ( $ file ) ; } return $ this -> ge... | Get the full path to upload file |
51,145 | protected function getImageUploadDisk ( ) { if ( $ diskInOption = array_get ( $ this -> uploadFieldOptions , 'disk' ) ) { return $ diskInOption ; } return property_exists ( $ this , 'imagesUploadDisk' ) ? $ this -> imagesUploadDisk : config ( 'imageup.upload_disk' , 'public' ) ; } | Get image upload disk |
51,146 | protected function validateImage ( $ file , $ fieldName , $ imageOptions ) { if ( $ rules = array_get ( $ imageOptions , 'rules' ) ) { $ this -> validationFactory ( ) -> make ( [ $ fieldName => $ file ] , [ $ fieldName => $ rules ] ) -> validate ( ) ; } } | Validate image file with given rules in option |
51,147 | protected function saveImage ( $ imageFile , $ image ) { $ this -> triggerBeforeSaveHook ( $ image ) ; $ imageQuality = array_get ( $ this -> uploadFieldOptions , 'resize_image_quality' , config ( 'imageup.resize_image_quality' ) ) ; $ imagePath = $ this -> getFileUploadPath ( $ imageFile ) ; $ this -> getStorageDisk (... | Save the image to disk |
51,148 | protected function updateModel ( $ imagePath , $ imageFieldName ) { $ this -> attributes [ $ imageFieldName ] = $ imagePath ; $ dispatcher = $ this -> getEventDispatcher ( ) ; self :: unsetEventDispatcher ( ) ; $ this -> save ( ) ; self :: setEventDispatcher ( $ dispatcher ) ; } | update the model field |
51,149 | protected function getCropOption ( $ imageFieldOptions ) { $ crop = array_get ( $ imageFieldOptions , 'crop' , false ) ; if ( isset ( $ this -> cropCoordinates ) && count ( $ this -> cropCoordinates ) == 2 ) { $ crop = $ this -> cropCoordinates ; } return $ crop ; } | Get the crop option |
51,150 | protected function autoUpload ( ) { foreach ( $ this -> getDefinedUploadFields ( ) as $ key => $ val ) { $ field = is_int ( $ key ) ? $ val : $ key ; $ options = array_wrap ( $ val ) ; $ autoUploadAllowed = array_get ( $ options , 'auto_upload' , $ this -> canAutoUploadImages ( ) ) ; if ( ! $ autoUploadAllowed ) { cont... | Auto image upload handler |
51,151 | protected function autoDeleteImage ( ) { if ( config ( 'imageup.auto_delete_images' ) ) { foreach ( $ this -> getDefinedUploadFields ( ) as $ field => $ options ) { $ field = is_numeric ( $ field ) ? $ options : $ field ; $ this -> deleteImage ( $ this -> getOriginal ( $ field ) ) ; } } } | Auto delete image handler |
51,152 | protected function triggerHook ( $ hook , $ image ) { if ( is_callable ( $ hook ) ) { $ hook ( $ image ) ; } if ( is_string ( $ hook ) ) { $ instance = app ( $ hook ) ; $ instance -> handle ( $ image ) ; } } | This will try to trigger the hook depending on the user definition . |
51,153 | protected function triggerBeforeSaveHook ( $ image ) { if ( isset ( $ this -> uploadFieldOptions [ 'before_save' ] ) ) { $ this -> triggerHook ( $ this -> uploadFieldOptions [ 'before_save' ] , $ image ) ; } return $ this ; } | Trigger user defined before save hook . |
51,154 | protected function triggerAfterSaveHook ( $ image ) { if ( isset ( $ this -> uploadFieldOptions [ 'after_save' ] ) ) { $ this -> triggerHook ( $ this -> uploadFieldOptions [ 'after_save' ] , $ image ) ; } return $ this ; } | Trigger user defined after save hook . |
51,155 | protected function handleImageUpload ( $ imageFile ) { $ image = $ this -> resizeImage ( $ imageFile , $ this -> uploadFieldOptions ) ; return $ this -> saveImage ( $ imageFile , $ image ) ; } | Process image upload |
51,156 | public function handleFileUpload ( $ file ) { $ this -> triggerBeforeSaveHook ( $ file ) ; $ filePath = $ this -> getFileUploadPath ( $ file ) ; $ this -> getStorageDisk ( ) -> put ( $ filePath , file_get_contents ( $ file ) , 'public' ) ; $ this -> triggerAfterSaveHook ( $ file ) ; return $ filePath ; } | Process file upload |
51,157 | protected function getByeGroup ( $ fighters ) { $ fighterCount = $ fighters -> count ( ) ; $ firstRoundGroupSize = $ this -> firstRoundGroupSize ( ) ; $ treeSize = $ this -> getTreeSize ( $ fighterCount , $ firstRoundGroupSize ) ; $ byeCount = $ treeSize - $ fighterCount ; return $ this -> createByeGroup ( $ byeCount )... | Calculate the Byes needed to fill the Championship Tree . |
51,158 | protected function pushEmptyGroupsToTree ( $ numFighters ) { if ( $ this -> championship -> hasPreliminary ( ) ) { $ numFightersElim = $ numFighters / $ this -> settings -> preliminaryGroupSize * 2 ; $ numRounds = intval ( log ( $ numFightersElim , 2 ) ) ; return $ this -> pushGroups ( $ numRounds , $ numFightersElim )... | Create empty groups after round 1 . |
51,159 | protected function generateFights ( ) { $ settings = $ this -> settings ; $ initialRound = 1 ; if ( $ this -> championship -> hasPreliminary ( ) && $ settings -> preliminaryGroupSize == 3 ) { $ groups = $ this -> championship -> groupsByRound ( 1 ) -> get ( ) ; foreach ( $ groups as $ numGroup => $ group ) { for ( $ nu... | Generate First Round Fights . |
51,160 | protected function generateAllTrees ( ) { $ this -> minFightersCheck ( ) ; $ usersByArea = $ this -> getFightersByArea ( ) ; $ this -> generateGroupsForRound ( $ usersByArea , 1 ) ; $ numFighters = count ( $ usersByArea -> collapse ( ) ) ; $ this -> pushEmptyGroupsToTree ( $ numFighters ) ; $ this -> addParentToChildre... | Generate all the groups and assign figthers to group |
51,161 | private function minFightersCheck ( ) { $ fighters = $ this -> getFighters ( ) ; $ areas = $ this -> settings -> fightingAreas ; $ fighterType = $ this -> championship -> category -> isTeam ? trans_choice ( 'laravel-tournaments::core.team' , 2 ) : trans_choice ( 'laravel-tournaments::core.competitor' , 2 ) ; $ minFight... | Check if there is enough fighters throw exception otherwise . |
51,162 | private function insertByes ( Collection $ fighters , $ numByeTotal ) { $ bye = $ this -> createByeFighter ( ) ; $ groupSize = $ this -> firstRoundGroupSize ( ) ; $ frequency = $ groupSize != 0 ? ( int ) floor ( count ( $ fighters ) / $ groupSize / $ groupSize ) : - 1 ; if ( $ frequency < $ groupSize ) { $ frequency = ... | Insert byes group alternated with full groups . |
51,163 | private function getMaxFightersByEntity ( $ userGroups ) : int { return $ userGroups -> sortByDesc ( function ( $ group ) { return $ group -> count ( ) ; } ) -> first ( ) -> count ( ) ; } | Get the biggest entity group . |
51,164 | private function repart ( $ fighterGroups , $ max ) { $ fighters = new Collection ( ) ; for ( $ i = 0 ; $ i < $ max ; $ i ++ ) { foreach ( $ fighterGroups as $ fighterGroup ) { $ fighter = $ fighterGroup -> values ( ) -> get ( $ i ) ; if ( $ fighter != null ) { $ fighters -> push ( $ fighter ) ; } } } return $ fighters... | Repart BYE in the tree . |
51,165 | public static function saveFights ( Collection $ groups , $ numGroup = 1 ) { $ competitor1 = $ competitor2 = null ; $ order = 1 ; foreach ( $ groups as $ group ) { $ fighters = $ group -> getFightersWithBye ( ) ; $ fighter1 = $ fighters -> get ( 0 ) ; $ fighter2 = $ fighters -> get ( 1 ) ; $ fighter3 = $ fighters -> ge... | Save all fights . |
51,166 | public static function saveFight2 ( FightersGroup $ group , $ numGroup = 1 , $ order = 1 ) { $ competitor1 = $ competitor2 = null ; $ fighters = $ group -> getFightersWithBye ( ) ; $ fighter1 = $ fighters -> get ( 0 ) ; $ fighter2 = $ fighters -> get ( 1 ) ; $ fighter3 = $ fighters -> get ( 2 ) ; switch ( $ numGroup ) ... | Save a Fight . |
51,167 | private function getFightersByEntity ( $ fighters ) : Collection { if ( ( $ this -> groupBy ) != null ) { return $ fighters -> groupBy ( $ this -> groupBy ) ; } return $ fighters -> chunk ( 1 ) ; } | Get Competitor s list ordered by entities Countries for Internation Tournament State for a National Tournament etc . |
51,168 | protected function getTreeSize ( $ fighterCount , $ groupSize ) { $ squareMultiplied = collect ( [ 1 , 2 , 4 , 8 , 16 , 32 , 64 ] ) -> map ( function ( $ item ) use ( $ groupSize ) { return $ item * $ groupSize ; } ) ; foreach ( $ squareMultiplied as $ limit ) { if ( $ fighterCount <= $ limit ) { $ treeSize = $ limit ;... | Get the size the first round will have . |
51,169 | protected function getFightersByArea ( ) { $ areas = $ this -> settings -> fightingAreas ; $ fighters = $ this -> getFighters ( ) ; $ fighterByEntity = $ this -> getFightersByEntity ( $ fighters ) ; $ fightersWithBye = $ this -> adjustFightersGroupWithByes ( $ fighters , $ fighterByEntity ) ; return $ fightersWithBye -... | Group Fighters by area . Here is where we fill with empty fighters |
51,170 | protected function destroyPreviousFights ( ) { $ arrGroupsId = $ this -> championship -> fightersGroups ( ) -> get ( ) -> pluck ( 'id' ) ; if ( count ( $ arrGroupsId ) > 0 ) { Fight :: destroy ( $ arrGroupsId ) ; } } | Destroy Previous Fights for demo . |
51,171 | public function generateNextRoundsFights ( ) { $ fightersCount = $ this -> championship -> competitors -> count ( ) + $ this -> championship -> teams -> count ( ) ; $ maxRounds = $ this -> getNumRounds ( $ fightersCount ) ; for ( $ numRound = 1 ; $ numRound < $ maxRounds ; $ numRound ++ ) { $ groupsByRound = $ this -> ... | Generate Fights for next rounds . |
51,172 | public function getRoundTitles ( ) { $ semiFinalTitles = [ 'Semi-Finals' , 'Final' ] ; $ quarterFinalTitles = [ 'Quarter-Finals' , 'Semi-Finals' , 'Final' ] ; $ roundTitle = [ 2 => [ 'Final' ] , 3 => $ semiFinalTitles , 4 => $ semiFinalTitles , 5 => $ semiFinalTitles , 6 => $ quarterFinalTitles , 7 => $ quarterFinalTit... | returns titles depending of number of rounds . |
51,173 | public function printRoundTitles ( ) { $ roundTitles = $ this -> getRoundTitles ( ) ; echo '<div id="round-titles-wrapper">' ; foreach ( $ roundTitles as $ key => $ roundTitle ) { $ left = $ key * ( $ this -> matchWrapperWidth + $ this -> roundSpacing - 1 ) ; echo '<div class="round-title" style="left: ' . $ left . 'px... | Print Round Titles . |
51,174 | public function competitorsWithBye ( ) : Collection { $ competitors = new Collection ( ) ; $ fgcs = FighterGroupCompetitor :: where ( 'fighters_group_id' , $ this -> id ) -> with ( 'competitor' ) -> get ( ) ; foreach ( $ fgcs as $ fgc ) { $ competitors -> push ( $ fgc -> competitor ?? new Competitor ( ) ) ; } return $ ... | Get the many 2 many relationship with the Null Rows . |
51,175 | public function hasDeterminedParent ( ) { if ( count ( $ this -> fighters ( ) ) > 1 ) { return false ; } foreach ( $ this -> children as $ child ) { if ( count ( $ child -> fighters ( ) ) > 1 ) { return false ; } } return true ; } | Check if we are able to fill the parent fight or not If one of the children has c1 x c2 then we must wait to fill parent . |
51,176 | public function run ( ) { if ( isset ( $ _GET [ 'state' ] , $ _GET [ 'code' ] ) ) { if ( $ _GET [ 'state' ] !== $ this -> state ) { $ this -> reportError ( 'Invalid state parameter' ) ; return ; } if ( ! file_put_contents ( $ this -> file , $ _GET [ 'code' ] , LOCK_EX ) ) { $ this -> reportError ( 'Failed to write auth... | Check state run logic set page content . |
51,177 | public function getEnvVar ( $ variable , $ sshUrl , $ refresh = false , $ ttl = 3600 ) { $ varName = $ this -> config -> get ( 'service.env_prefix' ) . $ variable ; $ cacheKey = 'env-' . $ sshUrl . '-' . $ varName ; $ cached = $ this -> cache -> fetch ( $ cacheKey ) ; if ( $ refresh || $ cached === false ) { $ args = [... | Read an environment variable from a remote application . |
51,178 | public function clearCaches ( $ sshUrl , array $ variables = [ 'APPLICATION' , 'RELATIONSHIPS' , 'ROUTES' ] ) { $ prefix = $ this -> config -> get ( 'service.env_prefix' ) ; foreach ( $ variables as $ variable ) { $ this -> cache -> delete ( 'env-' . $ sshUrl . '-' . $ prefix . $ variable ) ; } } | Clear caches for remote environment variables . |
51,179 | public function onException ( ConsoleExceptionEvent $ event ) { $ exception = $ event -> getException ( ) ; if ( $ exception instanceof ConnectException && strpos ( $ exception -> getMessage ( ) , 'cURL error 6' ) !== false ) { $ request = $ exception -> getRequest ( ) ; $ event -> setException ( new ConnectionFailedEx... | React to any console exceptions . |
51,180 | private function getAvailableVersions ( ) { if ( ! isset ( $ this -> availableVersions ) ) { $ this -> availableVersions = [ ] ; foreach ( $ this -> getManifest ( ) as $ key => $ item ) { if ( $ missing = array_diff ( self :: $ requiredKeys , array_keys ( $ item ) ) ) { throw new \ RuntimeException ( sprintf ( 'Manifes... | Get available versions to update to . |
51,181 | private function getRemoteVersionInfo ( Updater $ updater ) { $ version = $ this -> getCurrentRemoteVersion ( $ updater ) ; if ( $ version === false ) { throw new \ RuntimeException ( 'No remote versions found' ) ; } $ versionInfo = $ this -> getAvailableVersions ( ) ; if ( ! isset ( $ versionInfo [ $ version ] ) ) { t... | Get version information for the latest remote version . |
51,182 | private function getManifest ( ) { if ( ! isset ( $ this -> manifest ) ) { $ context = stream_context_create ( [ 'http' => [ 'timeout' => $ this -> manifestTimeout ] ] ) ; $ manifestContents = file_get_contents ( $ this -> manifestUrl , false , $ context ) ; if ( $ manifestContents === false ) { throw new \ RuntimeExce... | Download and decode the JSON manifest file . |
51,183 | private function filterByLocalMajorVersion ( array $ versions ) { list ( $ localMajorVersion , ) = explode ( '.' , $ this -> localVersion , 2 ) ; return array_filter ( $ versions , function ( $ version ) use ( $ localMajorVersion ) { list ( $ majorVersion , ) = explode ( '.' , $ version , 2 ) ; return $ majorVersion ==... | Filter a list of versions to those that match the current local version . |
51,184 | private function filterByPhpVersion ( array $ versions ) { $ versionInfo = $ this -> getAvailableVersions ( ) ; return array_filter ( $ versions , function ( $ version ) use ( $ versionInfo ) { if ( isset ( $ versionInfo [ $ version ] [ 'php' ] [ 'min' ] ) && version_compare ( PHP_VERSION , $ versionInfo [ $ version ] ... | Filter a list of versions to those that allow the current PHP version . |
51,185 | public function getSharedFileMounts ( array $ appConfig ) { $ sharedFileMounts = [ ] ; if ( ! empty ( $ appConfig [ 'mounts' ] ) ) { foreach ( $ this -> normalizeMounts ( $ appConfig [ 'mounts' ] ) as $ path => $ definition ) { if ( isset ( $ definition [ 'source_path' ] ) ) { $ sharedFileMounts [ $ path ] = $ definiti... | Get a list of shared file mounts configured for an app . |
51,186 | public function normalizeMounts ( array $ mounts ) { $ normalized = [ ] ; foreach ( $ mounts as $ path => $ definition ) { $ normalized [ $ this -> normalizeRelativePath ( $ path ) ] = $ this -> normalizeDefinition ( $ definition ) ; } return $ normalized ; } | Normalize a list of mounts . |
51,187 | public function validateMountPath ( $ inputPath , array $ mounts ) { $ normalized = $ this -> normalizeRelativePath ( $ inputPath ) ; if ( isset ( $ mounts [ $ normalized ] ) ) { return $ normalized ; } throw new \ InvalidArgumentException ( sprintf ( 'Mount not found: <error>%s</error>' , $ inputPath ) ) ; } | Validate and normalize a path to a mount . |
51,188 | private function normalizeDefinition ( $ definition ) { if ( ! is_array ( $ definition ) ) { if ( ! is_string ( $ definition ) || strpos ( $ definition , 'shared:files' ) === false ) { throw new \ RuntimeException ( 'Failed to parse mount definition: ' . json_encode ( $ definition ) ) ; } $ definition = [ 'source' => '... | Normalize a mount definition . |
51,189 | public static function isDrupal ( $ directory , $ depth = '< 2' ) { if ( ! is_dir ( $ directory ) ) { return false ; } $ finder = new Finder ( ) ; $ finder -> in ( $ directory ) -> files ( ) -> depth ( $ depth ) -> exclude ( [ 'node_modules' , 'vendor' ] ) -> name ( 'project.make*' ) -> name ( 'drupal-org.make*' ) ; fo... | Detect if there are any Drupal applications in a folder . |
51,190 | protected function checkIgnored ( $ filename , $ suggestion = null ) { if ( ! file_exists ( $ filename ) ) { return ; } if ( ! $ repositoryDir = $ this -> gitHelper -> getRoot ( $ this -> appRoot ) ) { return ; } $ relative = $ this -> fsHelper -> makePathRelative ( $ filename , $ repositoryDir ) ; if ( ! $ this -> git... | Check that an application file is ignored in . gitignore . |
51,191 | protected function getDrushFlags ( ) { $ drushFlags = [ '--yes' , ] ; $ verbosity = $ this -> stdErr -> getVerbosity ( ) ; if ( $ verbosity === OutputInterface :: VERBOSITY_QUIET ) { $ drushFlags [ ] = '--quiet' ; } elseif ( $ verbosity === OutputInterface :: VERBOSITY_DEBUG ) { $ drushFlags [ ] = '--debug' ; } elseif ... | Set up options to pass to the drush commands . |
51,192 | protected function findDrushMakeFile ( $ required = false , $ core = false ) { $ candidates = [ 'project.make.yml' , 'project.make' , 'drupal-org.make.yml' , 'drupal-org.make' , ] ; if ( ! empty ( $ this -> settings [ 'lock' ] ) ) { $ candidates = array_merge ( [ 'project.make.lock' , 'project.make.yml.lock' , 'drupal-... | Find the preferred Drush Make file in the app root . |
51,193 | protected function buildInProjectMode ( $ projectMake ) { $ drushHelper = $ this -> getDrushHelper ( ) ; $ drushHelper -> ensureInstalled ( ) ; $ drushFlags = $ this -> getDrushFlags ( ) ; $ drupalRoot = $ this -> getWebRoot ( ) ; $ args = array_merge ( [ 'make' , $ projectMake , $ drupalRoot ] , $ drushFlags ) ; if ( ... | Build in project mode i . e . just using a Drush make file . |
51,194 | protected function processSettingsPhp ( ) { if ( $ this -> copy ) { return ; } $ settingsPhpFile = $ this -> appRoot . '/settings.php' ; if ( file_exists ( $ settingsPhpFile ) ) { $ this -> stdErr -> writeln ( "Found a custom settings.php file: $settingsPhpFile" ) ; $ this -> fsHelper -> copy ( $ settingsPhpFile , $ th... | Handle a custom settings . php file for project and profile mode . |
51,195 | protected function getSearchQuery ( array $ args ) { return implode ( ' ' , array_map ( function ( $ term ) { return strpos ( $ term , ' ' ) ? '"' . $ term . '"' : $ term ; } , $ args ) ) ; } | Turn a list of command arguments into a search query . |
51,196 | public static function fork ( ) { $ pid = pcntl_fork ( ) ; if ( $ pid === - 1 ) { throw new \ RuntimeException ( 'Failed to fork PHP process' ) ; } elseif ( $ pid > 0 ) { declare ( ticks = 1 ) ; pcntl_signal ( SIGCHLD , function ( ) { exit ; } ) ; pcntl_signal ( SIGTERM , function ( ) { exit ( 1 ) ; } ) ; sleep ( 60 ) ... | Fork the current PHP process . |
51,197 | public function startProcess ( Process $ process , $ pidFile , OutputInterface $ log ) { $ this -> processes [ $ pidFile ] = $ process ; try { $ process -> start ( function ( $ type , $ buffer ) use ( $ log ) { $ output = $ log instanceof ConsoleOutputInterface && $ type === Process :: ERR ? $ log -> getErrorOutput ( )... | Start a managed external process . |
51,198 | public function monitor ( OutputInterface $ log ) { while ( count ( $ this -> processes ) ) { sleep ( 1 ) ; foreach ( $ this -> processes as $ pidFile => $ process ) { if ( ! file_exists ( $ pidFile ) ) { $ log -> writeln ( sprintf ( 'Process stopped: %s' , $ process -> getCommandLine ( ) ) ) ; $ process -> stop ( ) ; ... | Monitor processes and stop them if their PID file no longer exists . |
51,199 | protected function api ( ) { if ( ! isset ( $ this -> api ) ) { $ this -> api = $ this -> getService ( 'api' ) ; $ this -> api -> dispatcher -> addListener ( 'login_required' , [ $ this , 'login' ] ) ; $ this -> api -> dispatcher -> addListener ( 'environments_changed' , [ $ this , 'updateDrushAliases' ] ) ; } return $... | Set up the API object . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.