idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
43,500 | protected function throwException ( $ message , array $ relatedToken = null ) { if ( $ relatedToken ) $ message .= "\n(" . $ relatedToken [ 'type' ] . ' at ' . $ relatedToken [ 'line' ] . ':' . $ relatedToken [ 'offset' ] . ')' ; throw new Exception ( "Failed to parse Jade: $message" ) ; } | Throws a Parser - Exception . |
43,501 | public function getAdapter ( ) { if ( ! isset ( $ this -> adapter ) ) { $ adapter = $ this -> options [ 'adapter' ] ; $ className = strpos ( $ adapter , '\\' ) === false ? __NAMESPACE__ . '\\Renderer\\Adapter\\' . ucfirst ( $ this -> options [ 'adapter' ] ) : $ adapter ; if ( ! class_exists ( $ className ) ) throw new ... | Returns the adapter that actually renders the files . |
43,502 | protected function invalidate ( $ name , $ message , $ logger = null ) { Versioned :: withVersionedMode ( function ( ) use ( $ name ) { foreach ( [ Versioned :: LIVE , Versioned :: DRAFT ] as $ stage ) { Versioned :: set_stage ( $ stage ) ; $ this -> cache -> flushByName ( $ name ) ; } } ) ; if ( $ logger ) { $ logger ... | Invalidates a cache by a certain name and logs if available |
43,503 | private function doBeforeCompile ( ) : void { $ builder = $ this -> getContainerBuilder ( ) ; $ dispatcher = $ builder -> getDefinition ( $ this -> prefix ( 'dispatcher' ) ) ; $ subscribers = $ builder -> findByType ( EventSubscriberInterface :: class ) ; foreach ( $ subscribers as $ name => $ subscriber ) { $ dispatch... | Collect listeners and subscribers |
43,504 | private function doBeforeCompileLaziness ( ) : void { $ builder = $ this -> getContainerBuilder ( ) ; $ dispatcher = $ builder -> getDefinition ( $ this -> prefix ( 'dispatcher' ) ) ; $ subscribers = $ builder -> findByType ( EventSubscriberInterface :: class ) ; foreach ( $ subscribers as $ name => $ subscriber ) { $ ... | Collect listeners and subscribers in lazy - way |
43,505 | public function getCombinedConfig ( $ name ) { $ config = $ this -> defaultConfig ; if ( isset ( $ this -> config [ $ name ] ) && is_array ( $ this -> config [ $ name ] ) ) { $ config = $ this -> config [ $ name ] + $ config ; } else { throw new RuntimeException ( "Config '$name' doesn't exist, please check your config... | Get the default config combined with the provided config |
43,506 | public function flushByName ( $ name ) { $ this -> lockCacheAndRun ( function ( ) use ( $ name ) { $ keys = ( array ) $ this -> cache -> get ( $ name ) ; foreach ( array_keys ( $ keys ) as $ key ) { $ this -> cache -> delete ( $ key ) ; } $ this -> cache -> set ( $ name , [ ] ) ; } ) ; } | Flush the named cache block |
43,507 | protected function _setIdentifier ( $ request ) { $ key = $ this -> getConfig ( 'identifier' ) ; if ( ! is_callable ( $ this -> getConfig ( 'identifier' ) ) ) { throw new \ InvalidArgumentException ( 'Throttle identifier option must be a callable' ) ; } $ this -> _identifier = $ key ( $ request ) ; } | Sets the identifier class property . Uses Throttle default IP address based identifier unless a callable alternative is passed . |
43,508 | protected function _initCache ( ) { if ( ! Cache :: getConfig ( static :: $ cacheConfig ) ) { Cache :: setConfig ( static :: $ cacheConfig , [ 'className' => $ this -> _getDefaultCacheConfigClassName ( ) , 'prefix' => static :: $ cacheConfig . '_' . $ this -> _identifier , 'duration' => $ this -> getConfig ( 'interval'... | Initializes cache configuration . |
43,509 | protected function _touch ( ) { if ( Cache :: read ( $ this -> _identifier , static :: $ cacheConfig ) === false ) { Cache :: write ( $ this -> _identifier , 0 , static :: $ cacheConfig ) ; Cache :: write ( $ this -> _getCacheExpirationKey ( ) , strtotime ( $ this -> getConfig ( 'interval' ) , time ( ) ) , static :: $ ... | Atomically updates cache using default CakePHP increment offset 1 . |
43,510 | protected function _setHeaders ( $ response ) { $ headers = $ this -> getConfig ( 'headers' ) ; if ( ! is_array ( $ headers ) ) { return $ response ; } return $ response -> withHeader ( $ headers [ 'limit' ] , ( string ) $ this -> getConfig ( 'limit' ) ) -> withHeader ( $ headers [ 'remaining' ] , ( string ) $ this -> ... | Extends response with X - headers containing rate limiting information . |
43,511 | protected function style ( $ css , array $ attr = null ) { $ attr = $ this -> fixInternalAttr ( $ attr ) ; $ attr = $ this -> escaper -> attr ( $ attr ) ; return "<style $attr>$css</style>" ; } | Returns a style tag |
43,512 | public function endInternal ( ) { $ params = array_pop ( $ this -> capture ) ; $ css = ob_get_clean ( ) ; if ( isset ( $ params [ 'cond' ] ) ) { return $ this -> addCondInternal ( $ params [ 'cond' ] , $ css , $ params [ 'attr' ] , $ params [ 'pos' ] ) ; } return $ this -> addInternal ( $ css , $ params [ 'attr' ] , $ ... | Ends buffering and retains output for the most - recent internal . |
43,513 | protected function fixInternalAttr ( array $ attr = null ) { $ attr = ( array ) $ attr ; $ base = array ( 'type' => 'text/css' , 'media' => 'screen' , ) ; unset ( $ attr [ 'rel' ] ) ; unset ( $ attr [ 'href' ] ) ; return array_merge ( $ base , ( array ) $ attr ) ; } | Fixes the attributes for the internal stylesheet . |
43,514 | public function addInternal ( $ script , $ pos = 100 , array $ attr = array ( ) ) { $ attr = $ this -> attr ( null , $ attr ) ; $ tag = "<script $attr>$script</script>" ; $ this -> addElement ( $ pos , $ tag ) ; return $ this ; } | Adds internal script |
43,515 | public function addCondInternal ( $ cond , $ script , $ pos = 100 , array $ attr = array ( ) ) { $ cond = $ this -> escaper -> html ( $ cond ) ; $ attr = $ this -> attr ( null , $ attr ) ; $ tag = "<!--[if $cond]><script $attr>$script</script><![endif] ; $ this -> addElement ( $ pos , $ tag ) ; return $ this ; } | Add Conditional internal script |
43,516 | public function beginCondInternal ( $ cond , $ pos = 100 , array $ attr = array ( ) ) { $ this -> capture [ ] = array ( $ cond , $ pos , $ attr ) ; ob_start ( ) ; } | Begin Conditional Internal Capture |
43,517 | public function endInternal ( ) { $ script = ob_get_clean ( ) ; $ params = array_pop ( $ this -> capture ) ; if ( count ( $ params ) > 2 ) { return $ this -> addCondInternal ( $ params [ 0 ] , $ script , $ params [ 1 ] , $ params [ 2 ] ) ; } return $ this -> addInternal ( $ script , $ params [ 0 ] , $ params [ 1 ] ) ; ... | End internal script capture |
43,518 | protected function attr ( $ src = null , array $ attr = array ( ) ) { if ( null !== $ src ) { $ attr [ 'src' ] = $ src ; } $ attr [ 'type' ] = 'text/javascript' ; return $ this -> escaper -> attr ( $ attr ) ; } | Fix and escape script attributes |
43,519 | protected function getDeviceResolution ( $ name ) { Assert :: keyExists ( $ this -> devices , $ name , "Device '{$name}' not found." ) ; $ service = $ this -> getContainer ( ) -> get ( 'drupal.behat.component.resolution' ) ; $ service -> parse ( $ this -> devices [ $ name ] ) ; return $ service ; } | Get device resolution . |
43,520 | public function assertDeviceScreenResize ( $ device ) { $ resolution = $ this -> getDeviceResolution ( $ device ) ; $ this -> getSession ( ) -> resizeWindow ( ( int ) $ resolution -> getWidth ( ) , ( int ) $ resolution -> getHeight ( ) , 'current' ) ; } | Resize browser window according to the specified device . |
43,521 | public function assertBrowserWindowWidth ( $ size ) { $ actual = $ this -> getSession ( ) -> evaluateScript ( 'return window.innerWidth;' ) ; if ( $ actual != $ size ) { throw new ExpectationException ( "Browser window width expected to be {$size} but it is {$actual} instead." , $ this -> getSession ( ) ) ; } } | Resize browser window width . |
43,522 | public function assertBrowserWindowHeight ( $ size ) { $ actual = $ this -> getSession ( ) -> evaluateScript ( 'return window.outerHeight;' ) ; if ( $ actual != $ size ) { throw new ExpectationException ( "Browser window height expected to be {$size} but it is {$actual} instead." , $ this -> getSession ( ) ) ; } } | Resize browser window height . |
43,523 | public function takeScreenshot ( $ name = NULL ) { $ file_name = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR . $ name ; $ message = "Screenshot created in @file_name" ; $ this -> createScreenshot ( $ file_name , $ message , FALSE ) ; } | Save screenshot with a specific name . |
43,524 | public function screenshotForPhpNotices ( AfterStepScope $ event ) { $ environment = $ event -> getEnvironment ( ) ; $ class = 'Drupal\DrupalExtension\Context\MessageContext' ; if ( $ environment instanceof InitializedContextEnvironment && $ environment -> hasContextClass ( $ class ) ) { $ context = $ environment -> ge... | Make sure there is no PHP notice on the screen during tests . |
43,525 | public function takeScreenshotAfterFailedStep ( AfterStepScope $ event ) { if ( $ event -> getTestResult ( ) -> isPassed ( ) ) { return ; } try { $ step = $ event -> getStep ( ) ; if ( function_exists ( 'transliteration_clean_filename' ) ) { $ file_name = transliteration_clean_filename ( $ step -> getKeyword ( ) . '_' ... | Take a screenshot after failed steps or save the HTML for non js drivers . |
43,526 | public function createScreenshot ( $ file_name , $ message , $ ext = TRUE ) { if ( $ this -> getSession ( ) -> getDriver ( ) instanceof Selenium2Driver ) { if ( $ ext ) { $ file_name .= '.png' ; } $ screenshot = $ this -> getSession ( ) -> getDriver ( ) -> getScreenshot ( ) ; file_put_contents ( $ file_name , $ screens... | Create a screenshot or save the html . |
43,527 | public function iSetChosenElement ( $ locator , $ value ) { $ session = $ this -> getSession ( ) ; $ el = $ session -> getPage ( ) -> findField ( $ locator ) ; if ( empty ( $ el ) ) { throw new ExpectationException ( 'No such select element ' . $ locator , $ session ) ; } $ element_id = str_replace ( '-' , '_' , $ el -... | This is from a patch which is very much work - in - progress . |
43,528 | public function assertElementVisibility ( $ tag , $ text ) { $ element = $ this -> getSession ( ) -> getPage ( ) ; $ nodes = $ element -> findAll ( 'css' , $ tag ) ; foreach ( $ nodes as $ node ) { if ( $ node -> getText ( ) === $ text ) { $ this -> assertElementVisible ( $ text , $ node ) ; } } } | Assert presence of given element on the page . |
43,529 | public function assertElementNonVisibility ( $ tag , $ text ) { $ element = $ this -> getSession ( ) -> getPage ( ) ; $ nodes = $ element -> findAll ( 'css' , $ tag ) ; foreach ( $ nodes as $ node ) { if ( $ node -> getText ( ) === $ text ) { $ this -> assertElementNotVisible ( $ text , $ node ) ; } } } | Assert absence of given element on the page . |
43,530 | public function iShouldSeeTheField ( $ field ) { $ element = $ this -> getSession ( ) -> getPage ( ) ; $ result = $ element -> findField ( $ field ) ; $ this -> assertElementVisible ( $ field , $ result ) ; } | Assert presence of given field on the page . |
43,531 | public function iShouldNotSeeTheField ( $ field ) { $ element = $ this -> getSession ( ) -> getPage ( ) ; $ this -> assertElementNotVisible ( $ field , $ element -> findField ( $ field ) ) ; } | Assert absence of given field . |
43,532 | protected function assertElementVisible ( $ element , NodeElement $ node ) { try { if ( $ node && ! $ node -> isVisible ( ) ) { throw new ExpectationException ( sprintf ( "The element '%s' is not present on the page %s" , $ element , $ this -> getSession ( ) -> getCurrentUrl ( ) ) , $ this -> getSession ( ) ) ; } } cat... | Assert visibility of an element . |
43,533 | protected function assertElementNotVisible ( $ element , NodeElement $ node ) { try { if ( $ node && $ node -> isVisible ( ) ) { throw new ExpectationException ( sprintf ( "The field '%s' was present on the page %s and was not supposed to be" , $ element , $ this -> getSession ( ) -> getCurrentUrl ( ) ) , $ this -> get... | Assert non visibility of an element . |
43,534 | public function get ( $ name ) { $ key = $ this -> getConfig ( $ name ) ; if ( is_string ( $ key ) ) { if ( ! isset ( $ this -> objects [ $ key ] ) ) { $ this -> objects [ $ key ] = new \ Aimeos \ MW \ Filesystem \ Laravel ( $ this -> fsm -> disk ( $ key ) , $ this -> tempdir ) ; } return $ this -> objects [ $ key ] ; ... | Returns the file system for the given name |
43,535 | public function getSearchAttributes ( $ withsub = true ) { $ path = 'mshop/customer/manager/submanagers' ; return $ this -> getSearchAttributesBase ( $ this -> searchConfig , $ path , [ 'address' ] , $ withsub ) ; } | Returns the list attributes that can be used for searching . |
43,536 | public function resetParameters ( ) { if ( \ Drupal :: state ( ) -> get ( 'nuvole_web.drupal_extension.parameter_overrides' ) ) { \ Drupal :: state ( ) -> set ( 'nuvole_web.drupal_extension.parameter_overrides' , [ ] ) ; \ Drupal :: service ( 'kernel' ) -> rebuildContainer ( ) ; } } | Rebuild container on after scenario . |
43,537 | public function assertParameters ( $ name , $ expected ) { $ value = \ Drupal :: getContainer ( ) -> getParameter ( $ name ) ; Assert :: eq ( $ value , $ this -> castParameter ( $ expected ) ) ; } | Assert given service parameter has given value . |
43,538 | public function negateParameters ( $ name , $ expected ) { try { $ value = \ Drupal :: getContainer ( ) -> getParameter ( $ name ) ; Assert :: notEq ( $ value , $ this -> castParameter ( $ expected ) ) ; } catch ( ParameterNotFoundException $ e ) { } } | Assert given service parameter has not given value . |
43,539 | public function overrideParameters ( array $ parameters ) { $ this -> setServiceProvider ( ) ; foreach ( $ parameters as $ name => $ value ) { $ parameters [ $ name ] = $ this -> castParameter ( $ value ) ; } \ Drupal :: state ( ) -> set ( 'nuvole_web.drupal_extension.parameter_overrides' , $ parameters ) ; \ Drupal ::... | Apply parameters overrides and rebuild container . |
43,540 | public function assertElementType ( NodeElement $ element , $ type ) { if ( $ element -> getTagName ( ) !== $ type ) { throw new ExpectationException ( "The element is not a '$type'' field." , $ this -> getSession ( ) ) ; } } | Checks that the given element is of the given type . |
43,541 | public function assertMenuStructureForContent ( $ menu_name , TableNode $ table ) { $ menu_items = $ table -> getColumnsHash ( ) ; foreach ( $ menu_items as $ key => $ menu_item ) { $ node = $ this -> getCore ( ) -> loadNodeByName ( $ menu_item [ 'title' ] ) ; $ menu_items [ $ key ] [ 'uri' ] = "entity:node/{$this->get... | Create menu structure for nodes . |
43,542 | public function assertMenuStructure ( $ menu_name , TableNode $ table ) { try { $ this -> menuLinks = array_merge ( $ this -> menuLinks , $ this -> getCore ( ) -> createMenuStructure ( $ menu_name , $ table -> getColumnsHash ( ) ) ) ; } catch ( \ InvalidArgumentException $ e ) { throw new ExpectationException ( $ e -> ... | Create menu structure my adding menu links . |
43,543 | public function deleteMenuLinks ( AfterScenarioScope $ event ) { if ( $ this -> menuLinks ) { foreach ( $ this -> menuLinks as $ menu_link ) { $ this -> getCore ( ) -> entityDelete ( $ menu_link ) ; } $ this -> getCore ( ) -> clearMenuCache ( ) ; } } | Assert clean Watchdog after every step . |
43,544 | protected function process ( array $ stmts ) { $ table = 'users_address' ; $ this -> msg ( sprintf ( 'Rename "refid" to "parentid" in table "%1$s"' , $ table ) , 0 ) ; $ this -> status ( '' ) ; foreach ( $ stmts as $ column => $ stmts ) { $ this -> msg ( sprintf ( 'Checking column "%1$s"' , $ column ) , 1 ) ; if ( $ th... | Changes the column in table |
43,545 | public static function create ( $ settings ) { if ( isset ( $ settings ) && ( $ settings = self :: validateSettings ( $ settings ) ) ) { $ credentials = new Credentials ( $ settings [ 'consumerKey' ] , $ settings [ 'consumerSecret' ] , $ settings [ 'token' ] , $ settings [ 'tokenSecret' ] ) ; $ stack = HandlerStack :: ... | Creates an instance of BynderApi using the settings provided . |
43,546 | public function getAssetBankManager ( ) { if ( ! isset ( $ this -> assetBankManager ) ) { $ this -> assetBankManager = new AssetBankManager ( $ this -> requestHandler ) ; } return $ this -> assetBankManager ; } | Gets an instance of the asset bank manager to use for DAM queries . |
43,547 | public function getAccessToken ( ) { return $ this -> requestHandler -> sendRequestAsync ( 'POST' , 'api/v4/oauth/access_token/' ) -> then ( function ( $ tokenValues ) { parse_str ( $ tokenValues , $ tokenArray ) ; $ token = $ tokenArray [ 'oauth_token' ] ; $ tokenSecret = $ tokenArray [ 'oauth_token_secret' ] ; $ this... | Exchanges the authorised request token for a valid access token . If successful the request token is immediately expired and the access tokens are set in the credentials . |
43,548 | public function userLogin ( $ username , $ password ) { return $ this -> requestHandler -> sendRequestAsync ( 'POST' , 'api/v4/users/login/' , [ 'form_params' => [ 'username' => $ username , 'password' => $ password ] ] ) -> then ( function ( $ result ) { $ this -> requestHandler -> setAccessTokenCredentials ( $ result... | Log in a user with username and password . If successful the retrieves OAUTH access tokens . |
43,549 | protected static function validateSettings ( $ settings ) { if ( ! isset ( $ settings [ 'consumerKey' ] ) || ! isset ( $ settings [ 'consumerSecret' ] ) ) { return false ; } $ settings [ 'token' ] = isset ( $ settings [ 'token' ] ) ? $ settings [ 'token' ] : null ; $ settings [ 'tokenSecret' ] = isset ( $ settings [ 't... | Checks if the settings array passed is valid . |
43,550 | public static function create ( Credentials $ credentials , $ baseUrl , Client $ client = null ) { $ newOauthHandler = new OauthRequestHandler ( $ credentials , $ baseUrl ) ; $ newOauthHandler -> initOauthRequestClient ( $ client ) ; return $ newOauthHandler ; } | Creates an instance of OauthRequestHandler using the settings provided . |
43,551 | public function setAccessTokenCredentials ( $ token , $ tokenSecret ) { $ this -> credentials -> setToken ( $ token ) ; $ this -> credentials -> setTokenSecret ( $ tokenSecret ) ; $ this -> initOauthRequestClient ( ) ; } | Sets the Access token credentials and re - initialises the request client . |
43,552 | public function sendRequestAsync ( $ type , $ uri , $ options = null ) { $ request = null ; switch ( $ type ) { case 'GET' : $ request = $ this -> oauthRequestClient -> getAsync ( $ uri , $ options ) ; break ; case 'POST' : $ request = $ this -> oauthRequestClient -> postAsync ( $ uri , $ options ) ; break ; case 'DELE... | Sends a request to the Bynder API . All requests are async for now and the query array is parsed as request filter . |
43,553 | protected function getStubEntity ( $ entity_type , array $ values ) { $ entity = \ Drupal :: entityTypeManager ( ) -> getStorage ( $ entity_type ) -> create ( $ values ) ; if ( ! $ entity instanceof ContentEntityInterface ) { throw new EntityMalformedException ( "Only content entities are supported." ) ; } return $ ent... | Get stub entity . |
43,554 | protected function saveFile ( $ source ) { $ name = basename ( $ source ) ; $ path = realpath ( DRUPAL_ROOT . '/' . $ source ) ; $ uri = file_unmanaged_copy ( $ path , 'public://' . $ name , FILE_EXISTS_REPLACE ) ; $ file = File :: create ( [ 'uri' => $ uri ] ) ; $ file -> save ( ) ; return $ file ; } | Save a file and return its id . |
43,555 | public function isdir ( $ path ) { return in_array ( basename ( $ path ) , $ this -> fs -> directories ( dirname ( $ path ) ) ) ; } | Tests if the given path is a directory |
43,556 | public function mkdir ( $ path ) { try { $ this -> fs -> makeDirectory ( $ path ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , 0 , $ e ) ; } } | Creates a new directory for the given path |
43,557 | public function rmdir ( $ path ) { try { $ this -> fs -> deleteDirectory ( $ path ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , 0 , $ e ) ; } } | Deletes the directory for the given path |
43,558 | public function scan ( $ path = null ) { try { return array_merge ( $ this -> fs -> directories ( $ path ) , $ this -> fs -> files ( $ path ) ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , 0 , $ e ) ; } } | Returns an iterator over the entries in the given path |
43,559 | public function size ( $ path ) { try { return $ this -> fs -> size ( $ path ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , 0 , $ e ) ; } } | Returns the file size |
43,560 | public function time ( $ path ) { try { return $ this -> fs -> lastModified ( $ path ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , 0 , $ e ) ; } } | Returns the Unix time stamp for the file |
43,561 | public function rm ( $ path ) { try { $ this -> fs -> delete ( $ path ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , 0 , $ e ) ; } } | Deletes the file for the given path |
43,562 | public function readf ( $ path ) { if ( ( $ filename = tempnam ( $ this -> tempdir , 'ai-' ) ) === false ) { throw new Exception ( sprintf ( 'Unable to create file in "%1$s"' , $ this -> tempdir ) ) ; } if ( @ file_put_contents ( $ filename , $ this -> fs -> get ( $ path ) ) === false ) { throw new Exception ( sprintf ... | Reads the content of the remote file and writes it to a local one |
43,563 | public function reads ( $ path ) { try { $ content = $ this -> fs -> get ( $ path ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , 0 , $ e ) ; } if ( ( $ stream = tmpfile ( ) ) === false ) { throw new Exception ( 'Couldn\'t create temporary file' ) ; } if ( fwrite ( $ stream , $ content )... | Returns the stream descriptor for the file |
43,564 | public function write ( $ path , $ content ) { try { $ this -> fs -> put ( $ path , $ content ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , 0 , $ e ) ; } } | Writes the given content to the file |
43,565 | public function writef ( $ path , $ local ) { if ( ( $ content = @ file_get_contents ( $ local ) ) === false ) { throw new Exception ( sprintf ( 'Couldn\'t read file "%1$s"' , $ local ) ) ; } $ this -> write ( $ path , $ content ) ; } | Writes the content of the local file to the remote path |
43,566 | public function writes ( $ path , $ stream ) { if ( ( $ content = @ fread ( $ stream , 0x7ffffffd ) ) === false ) { $ error = error_get_last ( ) ; throw new Exception ( $ error [ 'message' ] ) ; } try { $ this -> fs -> put ( $ path , $ content ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ... | Write the content of the stream descriptor into the remote file |
43,567 | public function move ( $ from , $ to ) { try { $ this -> fs -> move ( $ from , $ to ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , 0 , $ e ) ; } } | Renames a file moves it to a new location or both at once |
43,568 | public function copy ( $ from , $ to ) { try { $ this -> fs -> copy ( $ from , $ to ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , 0 , $ e ) ; } } | Copies a file to a new location |
43,569 | public function uploadFile ( $ data ) { $ uploadedFilePromise = $ this -> getClosestUploadEndpoint ( ) -> then ( function ( ) use ( $ data ) { return $ this -> requestUploadInformationAsync ( $ data [ 'filePath' ] ) ; } ) -> then ( function ( $ uploadRequestInfo ) use ( $ data ) { if ( $ file = fopen ( $ data [ 'filePa... | Uploads a file with the data specified in the data parameter . |
43,570 | public function uploadChunkIterator ( $ file , $ filePath , $ uploadRequestInfo , $ numberOfChunks , & $ chunkNumber ) { while ( $ chunk = fread ( $ file , self :: CHUNK_SIZE ) ) { $ chunkNumber ++ ; yield $ this -> uploadChunkAsync ( $ filePath , $ chunk , $ uploadRequestInfo , $ numberOfChunks , $ chunkNumber ) ; } } | Iterator function used to control how many file upload promises are sent out . |
43,571 | private function uploadChunkAsync ( $ filePath , $ chunk , $ uploadRequestInfo , $ numberOfChunks , $ chunkNumber ) { return $ this -> amazonApi -> uploadPartToAmazon ( $ filePath , $ this -> awsBucket , $ uploadRequestInfo , $ chunkNumber , $ chunk , $ numberOfChunks ) -> then ( function ( ) use ( $ uploadRequestInfo ... | The upload chunk logic function . Gets the closest Amazon endpoint uploads the chunk to Amazon and registers it in Bynder . |
43,572 | private function getClosestUploadEndpoint ( ) { if ( isset ( $ this -> awsBucket ) ) { return new Promise \ FulfilledPromise ( $ this -> awsBucket ) ; } else { return $ this -> requestHandler -> sendRequestAsync ( 'GET' , 'api/upload/endpoint' ) -> then ( function ( $ result ) { $ this -> awsBucket = $ result ; return ... | Gets the closest Amazon S3 bucket location to upload to . |
43,573 | private function registerChunkAsync ( $ uploadRequestInfo , $ chunkNumber ) { $ s3Filename = sprintf ( "%s/p%d" , $ uploadRequestInfo [ 's3_filename' ] , $ chunkNumber ) ; $ data = [ 'id' => $ uploadRequestInfo [ 's3file' ] [ 'uploadid' ] , 'targetid' => $ uploadRequestInfo [ 's3file' ] [ 'targetid' ] , 'filename' => $... | Registers a temporary chunk in Bynder . |
43,574 | private function hasFinishedSuccessfullyAsync ( $ finalizeResponse ) { $ promises = $ this -> pollStatusIterator ( $ finalizeResponse ) ; $ eachPromises = new Promise \ EachPromise ( $ promises , [ 'concurrency' => 1 , 'fulfilled' => function ( $ pollStatus , $ i , $ promise ) { if ( $ pollStatus != null ) { if ( ! emp... | Polls Bynder to confirm all chunks were uploaded and registered successfully in Bynder . |
43,575 | public function pollStatusIterator ( $ finalizeResponse ) { $ iterations = 0 ; while ( $ iterations < self :: MAX_POLLING_ITERATIONS ) { $ delay = $ iterations == 0 ? 0 : self :: POLLING_IDLE_TIME ; yield $ this -> pollStatusAsync ( [ 'items' => $ finalizeResponse [ 'importId' ] ] , $ delay ) ; $ iterations ++ ; } } | Generates polling promises sleeping between each request and limiting it to 1 thread to make sure enough time passes after file upload . |
43,576 | private function saveMediaAsync ( $ data ) { $ uri = "api/v4/media/save/" ; if ( isset ( $ data [ 'mediaId' ] ) ) { $ uri = sprintf ( "api/v4/media/" . $ data [ 'mediaId' ] . "/save/" ) ; unset ( $ data [ 'mediaId' ] ) ; } return $ this -> requestHandler -> sendRequestAsync ( 'POST' , $ uri , [ 'form_params' => $ data ... | Saves the file in the Bynder Asset Bank . This can be either a new or existing file depending on whether or not the mediaId parameter is passed . |
43,577 | protected function visitContentPage ( $ op , $ type , $ title ) { $ nid = $ this -> getCore ( ) -> getEntityIdByLabel ( 'node' , $ type , $ title ) ; $ path = [ 'view' => "node/$nid" , 'edit' => "node/$nid/edit" , 'delete' => "node/$nid/delete" , ] ; $ this -> visitPath ( $ path [ $ op ] ) ; } | Provides a common step definition callback for node pages . |
43,578 | public function userCanContent ( $ name , $ op , $ title ) { $ op = strtr ( $ op , [ 'edit' => 'update' ] ) ; $ node = $ this -> getCore ( ) -> loadNodeByName ( $ title ) ; $ access = $ this -> getCore ( ) -> nodeAccess ( $ op , $ name , $ node ) ; if ( ! $ access ) { throw new \ Exception ( "{$name} cannot {$op} '{$ti... | Assert that given user can perform given operation on given content . |
43,579 | public function assertContentEditLink ( $ link , $ title ) { if ( ! $ this -> getContentEditLink ( $ link , $ title ) ) { throw new ExpectationException ( "No '$link' link to edit '$title' has been found." , $ this -> getSession ( ) ) ; } } | Assert presence of content edit link given its name and content title . |
43,580 | public function assertContent ( PyStringNode $ string ) { $ values = $ this -> getYamlParser ( ) -> parse ( $ string ) ; $ message = __METHOD__ . ": Required fields 'type', 'title' and 'langcode' not found." ; Assert :: keyExists ( $ values , 'type' , $ message ) ; Assert :: keyExists ( $ values , 'title' , $ message )... | Create content defined in YAML format . |
43,581 | public function assertTranslation ( $ content_type , $ title , PyStringNode $ string ) { $ values = $ this -> getYamlParser ( ) -> parse ( $ string ) ; Assert :: keyExists ( $ values , 'langcode' , __METHOD__ . ": Required field 'langcode' not found." ) ; $ nid = $ this -> getCore ( ) -> getEntityIdByLabel ( 'node' , $... | Assert translation for given content . |
43,582 | protected function getContentEditLink ( $ link , $ title ) { $ node = $ this -> getCore ( ) -> loadNodeByName ( $ title ) ; $ element = $ this -> getSession ( ) -> getPage ( ) ; $ locator = ( $ link ? array ( 'link' , sprintf ( "'%s'" , $ link ) ) : array ( 'link' , "." ) ) ; $ links = $ element -> findAll ( 'named' , ... | Get the edit link for a node . |
43,583 | protected function createRequest ( \ Illuminate \ Http \ Request $ nativeRequest ) { $ files = ServerRequestFactory :: normalizeFiles ( $ this -> getFiles ( $ nativeRequest -> files -> all ( ) ) ) ; $ server = ServerRequestFactory :: normalizeServer ( $ nativeRequest -> server -> all ( ) ) ; $ headers = $ nativeRequest... | Transforms a Symfony request into a PSR - 7 request object |
43,584 | protected function getFiles ( array $ files ) { $ list = [ ] ; foreach ( $ files as $ key => $ value ) { if ( $ value instanceof \ Symfony \ Component \ HttpFoundation \ File \ UploadedFile ) { $ list [ $ key ] = new \ Zend \ Diactoros \ UploadedFile ( $ value -> getRealPath ( ) , $ value -> getSize ( ) , $ value -> ge... | Converts Symfony uploaded files array to the PSR - 7 one . |
43,585 | public function assertEmailSentWithProperties ( TableNode $ table ) { $ last_mail = $ this -> getLastEmail ( ) ; foreach ( $ table -> getRowsHash ( ) as $ name => $ value ) { Assert :: keyExists ( $ last_mail , $ name ) ; Assert :: eq ( $ last_mail [ $ name ] , $ value ) ; } } | Assert that the email that has been sent has the given properties . |
43,586 | public function beforeScenarioNoContactFlood ( BeforeScenarioScope $ scope ) { $ config = $ this -> getCore ( ) -> getEditableConfig ( 'contact.settings' ) ; $ this -> contactSettings = $ config -> getData ( ) ; $ config -> set ( 'flood.limit' , 100000 ) ; $ config -> set ( 'flood.interval' , 100000 ) ; $ config -> sav... | Increase value of contact form flooding . |
43,587 | public function afterScenarioNoContactFlood ( AfterScenarioScope $ scope ) { $ config = $ this -> getCore ( ) -> getEditableConfig ( 'contact.settings' ) ; $ config -> setData ( $ this -> contactSettings ) -> save ( ) ; } | Restore contact form flooding settings . |
43,588 | protected function getCollectedEmails ( ) { $ this -> getCore ( ) -> state ( ) -> resetCache ( ) ; $ test_mail_collector = $ this -> getCore ( ) -> state ( ) -> get ( 'system.test_mail_collector' ) ; if ( ! $ test_mail_collector ) { $ test_mail_collector = [ ] ; } return $ test_mail_collector ; } | Get collected emails . |
43,589 | public function shouldPrecede ( $ first , $ second ) { $ page = $ this -> getSession ( ) -> getPage ( ) -> getText ( ) ; $ pos1 = strpos ( $ page , $ first ) ; if ( $ pos1 === FALSE ) { throw new ExpectationException ( "Text not found: '$first'." , $ this -> getSession ( ) ) ; } $ pos2 = strpos ( $ page , $ second ) ; ... | Assert first element precedes second one . |
43,590 | public function iFillInTheRichTextEditorWith ( $ label , $ text ) { $ field = $ this -> getSession ( ) -> getPage ( ) -> findField ( $ label ) ; if ( NULL === $ field ) { throw new \ Exception ( sprintf ( 'Field "%s" not found.' , $ label ) ) ; } $ args_as_js_object = json_encode ( [ 'ckeditor_instance_id' => $ field -... | Fill CKEditor with given value . |
43,591 | public function manuallyCreateNodes ( $ type , TableNode $ nodesTable ) { $ type = $ this -> getCore ( ) -> convertLabelToNodeTypeId ( $ type ) ; foreach ( $ nodesTable -> getHash ( ) as $ nodeHash ) { $ this -> getSession ( ) -> visit ( $ this -> locatePath ( "/node/add/$type" ) ) ; $ element = $ this -> getSession ( ... | Creates content by filling specified form fields via the UI . |
43,592 | public function submitContentForm ( ) { $ element = $ this -> getSession ( ) -> getPage ( ) ; $ submit = $ element -> findButton ( $ this -> getDrupalText ( 'node_submit_label' ) ) ; if ( empty ( $ submit ) ) { throw new \ Exception ( sprintf ( "No submit button at %s" , $ this -> getSession ( ) -> getCurrentUrl ( ) ) ... | Submit node form using node_submit_label value . |
43,593 | public function iShouldSeeInTheHeader ( $ header , $ value ) { $ headers = $ this -> getSession ( ) -> getResponseHeaders ( ) ; if ( $ headers [ $ header ] != $ value ) { throw new \ Exception ( sprintf ( "Did not see %s with value %s." , $ header , $ value ) ) ; } } | Assert string in HTTP response header . |
43,594 | public function invalidateCacheTags ( TableNode $ table ) { $ tags = [ ] ; foreach ( $ table -> getRows ( ) as $ row ) { $ tags [ ] = $ row [ 0 ] ; } $ this -> getCore ( ) -> invalidateCacheTags ( $ tags ) ; } | Invalidate cache tags . |
43,595 | public function fillInDrupalAutocomplete ( $ locator , $ text ) { $ session = $ this -> getSession ( ) ; $ el = $ session -> getPage ( ) -> findField ( $ locator ) ; if ( empty ( $ el ) ) { throw new ExpectationException ( 'No such autocomplete element ' . $ locator , $ session ) ; } $ el -> setValue ( $ text ) ; try {... | Fill out autocomplete fields based on gist . |
43,596 | public function parse ( $ resolution ) { preg_match_all ( self :: RESOLUTION_FORMAT , $ resolution , $ matches ) ; $ message = "Cannot parse provided resolution '{$resolution}'. It must be in the following format: 360x640" ; Assert :: notEmpty ( $ matches , $ message ) ; Assert :: keyExists ( $ matches , 0 , $ message ... | Parse resolution . |
43,597 | public function parse ( PyStringNode $ node ) { $ strings = $ node -> getStrings ( ) ; if ( $ strings ) { preg_match ( '/^(\s+)/' , $ strings [ 0 ] , $ matches ) ; $ indentation_size = isset ( $ matches [ 1 ] ) ? strlen ( $ matches [ 1 ] ) : 0 ; foreach ( $ strings as $ key => $ string ) { $ strings [ $ key ] = substr ... | Parse YAML contained in a PyString node . |
43,598 | protected function visitTermPage ( $ op , $ type , $ name ) { $ type = $ this -> getCore ( ) -> convertLabelToTermTypeId ( $ type ) ; $ term = $ this -> getCore ( ) -> loadTaxonomyTermByName ( $ type , $ name ) ; if ( ! empty ( $ term ) ) { $ path = [ 'view' => "taxonomy/term/{$this->getCore()->getTaxonomyTermId($term)... | Provides a common step definition callback for taxonomy term pages . |
43,599 | public function assertSelectOptions ( $ select , TableNode $ options ) { if ( ! $ field = $ this -> getSession ( ) -> getPage ( ) -> findField ( $ select ) ) { throw new ExpectationException ( "Field '$select' not found." , $ this -> getSession ( ) ) ; } $ this -> assertElementType ( $ field , 'select' ) ; $ expected_o... | Checks that the given select field has the options listed in the table . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.