idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
1,000 | public function regionFillField ( $ field , $ value , $ region ) { $ field = $ this -> fixStepArgument ( $ field ) ; $ value = $ this -> fixStepArgument ( $ value ) ; $ regionObj = $ this -> getRegion ( $ region ) ; $ regionObj -> fillField ( $ field , $ value ) ; } | Fills in a form field with id|name|title|alt|value in the specified region . |
1,001 | public function assertRegionHeading ( $ heading , $ region ) { $ regionObj = $ this -> getRegion ( $ region ) ; foreach ( array ( 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' ) as $ tag ) { $ elements = $ regionObj -> findAll ( 'css' , $ tag ) ; if ( ! empty ( $ elements ) ) { foreach ( $ elements as $ element ) { if ( trim... | Find a heading in a specific region . |
1,002 | protected function getUser ( ) { trigger_error ( 'DrupalSubContextBase::getUser() is deprecated. Use RawDrupalContext::getUserManager()->getCurrentUser() instead.' , E_USER_DEPRECATED ) ; $ user = $ this -> getUserManager ( ) -> getCurrentUser ( ) ; if ( empty ( $ user ) ) { throw new \ Exception ( 'No user is logged i... | Get the currently logged in user from DrupalContext . |
1,003 | public function getDrupalParameter ( $ name ) { return isset ( $ this -> drupalParameters [ $ name ] ) ? $ this -> drupalParameters [ $ name ] : null ; } | Returns a specific Drupal parameter . |
1,004 | public function getDrupalText ( $ name ) { $ text = $ this -> getDrupalParameter ( 'text' ) ; if ( ! isset ( $ text [ $ name ] ) ) { throw new \ Exception ( sprintf ( 'No such Drupal string: %s' , $ name ) ) ; } return $ text [ $ name ] ; } | Returns a specific Drupal text value . |
1,005 | public function getDrupalSelector ( $ name ) { $ text = $ this -> getDrupalParameter ( 'selectors' ) ; if ( ! isset ( $ text [ $ name ] ) ) { throw new \ Exception ( sprintf ( 'No such selector configured: %s' , $ name ) ) ; } return $ text [ $ name ] ; } | Returns a specific CSS selector . |
1,006 | public static function alterNodeParameters ( BeforeNodeCreateScope $ scope ) { $ node = $ scope -> getEntity ( ) ; $ api_version = null ; $ driver = $ scope -> getContext ( ) -> getDrupal ( ) -> getDriver ( ) ; if ( $ driver instanceof \ Drupal \ Driver \ DrupalDriver ) { $ api_version = $ scope -> getContext ( ) -> ge... | Massage node values to match the expectations on different Drupal versions . |
1,007 | public function cleanNodes ( ) { foreach ( $ this -> nodes as $ node ) { $ this -> getDriver ( ) -> nodeDelete ( $ node ) ; } $ this -> nodes = array ( ) ; } | Remove any created nodes . |
1,008 | public function cleanUsers ( ) { if ( $ this -> userManager -> hasUsers ( ) ) { foreach ( $ this -> userManager -> getUsers ( ) as $ user ) { $ this -> getDriver ( ) -> userDelete ( $ user ) ; } $ this -> getDriver ( ) -> processBatch ( ) ; $ this -> userManager -> clearUsers ( ) ; if ( $ this -> getAuthenticationManag... | Remove any created users . |
1,009 | public function cleanTerms ( ) { foreach ( $ this -> terms as $ term ) { $ this -> getDriver ( ) -> termDelete ( $ term ) ; } $ this -> terms = array ( ) ; } | Remove any created terms . |
1,010 | public function cleanRoles ( ) { foreach ( $ this -> roles as $ rid ) { $ this -> getDriver ( ) -> roleDelete ( $ rid ) ; } $ this -> roles = array ( ) ; } | Remove any created roles . |
1,011 | public function cleanLanguages ( ) { foreach ( $ this -> languages as $ language ) { $ this -> getDriver ( ) -> languageDelete ( $ language ) ; unset ( $ this -> languages [ $ language -> langcode ] ) ; } } | Remove any created languages . |
1,012 | protected function dispatchHooks ( $ scopeType , \ stdClass $ entity ) { $ fullScopeClass = 'Drupal\\DrupalExtension\\Hook\\Scope\\' . $ scopeType ; $ scope = new $ fullScopeClass ( $ this -> getDrupal ( ) -> getEnvironment ( ) , $ this , $ entity ) ; $ callResults = $ this -> dispatcher -> dispatchScopeHooks ( $ scope... | Dispatch scope hooks . |
1,013 | public function nodeCreate ( $ node ) { $ this -> dispatchHooks ( 'BeforeNodeCreateScope' , $ node ) ; $ this -> parseEntityFields ( 'node' , $ node ) ; $ saved = $ this -> getDriver ( ) -> createNode ( $ node ) ; $ this -> dispatchHooks ( 'AfterNodeCreateScope' , $ saved ) ; $ this -> nodes [ ] = $ saved ; return $ sa... | Create a node . |
1,014 | public function parseEntityFields ( $ entity_type , \ stdClass $ entity ) { $ multicolumn_field = '' ; $ multicolumn_fields = array ( ) ; foreach ( clone $ entity as $ field => $ field_value ) { if ( strpos ( $ field , ':' ) === false ) { $ multicolumn_field = '' ; } elseif ( strpos ( $ field , ':' , 1 ) !== false ) { ... | Parses the field values and turns them into the format expected by Drupal . |
1,015 | public function termCreate ( $ term ) { $ this -> dispatchHooks ( 'BeforeTermCreateScope' , $ term ) ; $ this -> parseEntityFields ( 'taxonomy_term' , $ term ) ; $ saved = $ this -> getDriver ( ) -> createTerm ( $ term ) ; $ this -> dispatchHooks ( 'AfterTermCreateScope' , $ saved ) ; $ this -> terms [ ] = $ saved ; re... | Create a term . |
1,016 | public function languageCreate ( \ stdClass $ language ) { $ this -> dispatchHooks ( 'BeforeLanguageCreateScope' , $ language ) ; $ language = $ this -> getDriver ( ) -> languageCreate ( $ language ) ; if ( $ language ) { $ this -> dispatchHooks ( 'AfterLanguageCreateScope' , $ language ) ; $ this -> languages [ $ lang... | Creates a language . |
1,017 | protected function getContext ( $ class ) { $ environment = $ this -> drupal -> getEnvironment ( ) ; if ( ! $ environment instanceof InitializedContextEnvironment ) { throw new \ Exception ( 'Cannot retrieve contexts when the environment is not yet initialized.' ) ; } foreach ( $ environment -> getContexts ( ) as $ con... | Returns the Behat context that corresponds with the given class name . |
1,018 | private function findSubContextClasses ( ) { $ class_names = array ( ) ; if ( isset ( $ this -> parameters [ 'subcontexts' ] ) ) { $ paths = array ( ) ; if ( $ this -> parameters [ 'subcontexts' ] [ 'autoload' ] ) { foreach ( $ this -> drupal -> getDrivers ( ) as $ name => $ driver ) { if ( $ driver instanceof SubDrive... | Finds and loads available subcontext classes . |
1,019 | private function findAvailableSubContexts ( $ path , $ pattern = '/^.+\.behat\.inc/i' ) { if ( isset ( static :: $ subContexts [ $ pattern ] [ $ path ] ) ) { return static :: $ subContexts [ $ pattern ] [ $ path ] ; } static :: $ subContexts [ $ pattern ] [ $ path ] = array ( ) ; $ fileIterator = new RegexIterator ( ne... | Find Sub - contexts matching a given pattern located at the passed path . |
1,020 | private function loadSubContexts ( $ subcontexts ) { foreach ( $ subcontexts as $ path => $ subcontext ) { if ( ! file_exists ( $ path ) ) { throw new \ RuntimeException ( sprintf ( 'Subcontext path %s path does not exist.' , $ path ) ) ; } require_once $ path ; } } | Load each subcontext file . |
1,021 | public function castUsersTable ( TableNode $ user_table ) { $ aliases = array ( 'country' => 'field_post_address:country' , 'city' => 'field_post_address:locality' , 'street' => 'field_post_address:thoroughfare' , 'postcode' => 'field_post_address:postal_code' , ) ; $ table = $ user_table -> getTable ( ) ; reset ( $ ta... | Transforms long address field columns into shorter aliases . |
1,022 | public function transformPostContentTable ( TableNode $ post_table ) { $ aliases = array ( 'reference' => 'field_post_reference' , 'date' => 'field_post_date' , 'links' => 'field_post_links' , 'select' => 'field_post_select' , 'address' => 'field_post_address' , ) ; $ table = $ post_table -> getTable ( ) ; array_walk (... | Transforms human readable field names into machine names . |
1,023 | public function assertAuthenticatedByUsernameAndPassword ( $ name , $ password ) { $ user = ( object ) [ 'name' => $ name , 'pass' => $ password , ] ; $ this -> userCreate ( $ user ) ; $ this -> login ( $ user ) ; } | Creates and authenticates a user with the given username and password . |
1,024 | public function fileShouldContain ( $ path , PyStringNode $ text ) { $ path = $ this -> workingDir . '/' . $ path ; PHPUnit_Framework_Assert :: assertFileExists ( $ path ) ; $ fileContent = trim ( file_get_contents ( $ path ) ) ; if ( "\n" !== PHP_EOL ) { $ fileContent = str_replace ( PHP_EOL , "\n" , $ fileContent ) ;... | Checks whether specified file exists and contains specified string . |
1,025 | private function loadParameters ( ContainerBuilder $ container , array $ config ) { $ drupal_parameters = array ( ) ; foreach ( $ config as $ key => $ value ) { $ drupal_parameters [ $ key ] = $ value ; } $ container -> setParameter ( 'drupal.parameters' , $ drupal_parameters ) ; $ container -> setParameter ( 'drupal.r... | Load test parameters . |
1,026 | private function loadDrupal ( FileLoader $ loader , ContainerBuilder $ container , array $ config ) { if ( isset ( $ config [ 'drupal' ] ) ) { $ loader -> load ( 'drivers/drupal.yml' ) ; $ container -> setParameter ( 'drupal.driver.drupal.drupal_root' , $ config [ 'drupal' ] [ 'drupal_root' ] ) ; } } | Load the Drupal driver . |
1,027 | private function loadDrush ( FileLoader $ loader , ContainerBuilder $ container , array $ config ) { if ( isset ( $ config [ 'drush' ] ) ) { $ loader -> load ( 'drivers/drush.yml' ) ; if ( ! isset ( $ config [ 'drush' ] [ 'alias' ] ) && ! isset ( $ config [ 'drush' ] [ 'root' ] ) ) { throw new \ RuntimeException ( 'Dru... | Load the Drush driver . |
1,028 | private function setDrushOptions ( ContainerBuilder $ container , array $ config ) { if ( isset ( $ config [ 'drush' ] [ 'global_options' ] ) ) { $ definition = $ container -> getDefinition ( 'drupal.driver.drush' ) ; $ definition -> addMethodCall ( 'setArguments' , array ( $ config [ 'drush' ] [ 'global_options' ] ) )... | Set global drush arguments . |
1,029 | private function processEnvironmentReaderPass ( ContainerBuilder $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , ContextExtension :: READER_TAG ) ; $ definition = $ container -> getDefinition ( 'drupal.context.environment.reader' ) ; foreach ( $ references as $ reference ... | Process the Environment Reader pass . |
1,030 | private function processClassGenerator ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Drupal\DrupalExtension\Context\ContextClass\ClassGenerator' ) ; $ container -> setDefinition ( ContextExtension :: CLASS_GENERATOR_TAG . '.simple' , $ definition ) ; } | Switch to custom class generator . |
1,031 | public function getTableRow ( Element $ element , $ search ) { $ rows = $ element -> findAll ( 'css' , 'tr' ) ; if ( empty ( $ rows ) ) { throw new \ Exception ( sprintf ( 'No rows found on the page %s' , $ this -> getSession ( ) -> getCurrentUrl ( ) ) ) ; } foreach ( $ rows as $ row ) { if ( strpos ( $ row -> getText ... | Retrieve a table row containing specified text from a given element . |
1,032 | public function assertTextInTableRow ( $ text , $ rowText ) { $ row = $ this -> getTableRow ( $ this -> getSession ( ) -> getPage ( ) , $ rowText ) ; if ( strpos ( $ row -> getText ( ) , $ text ) === false ) { throw new \ Exception ( sprintf ( 'Found a row containing "%s", but it did not contain the text "%s".' , $ row... | Find text in a table row containing given text . |
1,033 | public function createNode ( $ type , $ title ) { $ node = ( object ) array ( 'title' => $ title , 'type' => $ type , ) ; $ saved = $ this -> nodeCreate ( $ node ) ; $ this -> getSession ( ) -> visit ( $ this -> locatePath ( '/node/' . $ saved -> nid ) ) ; } | Creates content of the given type . |
1,034 | public function createMyNode ( $ type , $ title ) { if ( $ this -> getUserManager ( ) -> currentUserIsAnonymous ( ) ) { throw new \ Exception ( sprintf ( 'There is no current logged in user to create a node for.' ) ) ; } $ node = ( object ) array ( 'title' => $ title , 'type' => $ type , 'body' => $ this -> getRandom (... | Creates content authored by the current user . |
1,035 | public function assertEditNodeOfType ( $ type ) { $ node = ( object ) array ( 'type' => $ type , 'title' => "Test $type" , ) ; $ saved = $ this -> nodeCreate ( $ node ) ; $ this -> getSession ( ) -> visit ( $ this -> locatePath ( '/node/' . $ saved -> nid . '/edit' ) ) ; $ this -> assertSession ( ) -> statusCodeEquals ... | Asserts that a given content type is editable . |
1,036 | public function createTerm ( $ vocabulary , $ name ) { $ term = ( object ) array ( 'name' => $ name , 'vocabulary_machine_name' => $ vocabulary , 'description' => $ this -> getRandom ( ) -> name ( 255 ) , ) ; $ saved = $ this -> termCreate ( $ term ) ; $ this -> getSession ( ) -> visit ( $ this -> locatePath ( '/taxono... | Creates a term on an existing vocabulary . |
1,037 | public function createUsers ( TableNode $ usersTable ) { foreach ( $ usersTable -> getHash ( ) as $ userHash ) { $ roles = array ( ) ; if ( isset ( $ userHash [ 'roles' ] ) ) { $ roles = explode ( ',' , $ userHash [ 'roles' ] ) ; $ roles = array_filter ( array_map ( 'trim' , $ roles ) ) ; unset ( $ userHash [ 'roles' ]... | Creates multiple users . |
1,038 | public function createTerms ( $ vocabulary , TableNode $ termsTable ) { foreach ( $ termsTable -> getHash ( ) as $ termsHash ) { $ term = ( object ) $ termsHash ; $ term -> vocabulary_machine_name = $ vocabulary ; $ this -> termCreate ( $ term ) ; } } | Creates one or more terms on an existing vocabulary . |
1,039 | public function createLanguages ( TableNode $ langcodesTable ) { foreach ( $ langcodesTable -> getHash ( ) as $ row ) { $ language = ( object ) array ( 'langcode' => $ row [ 'languages' ] , ) ; $ this -> languageCreate ( $ language ) ; } } | Creates one or more languages . |
1,040 | public function iPutABreakpoint ( ) { fwrite ( STDOUT , "\033[s \033[93m[Breakpoint] Press \033[1;93m[RETURN]\033[0;93m to continue, or 'q' to quit...\033[0m" ) ; do { $ line = trim ( fgets ( STDIN , 1024 ) ) ; $ charCode = ord ( $ line ) ; switch ( $ charCode ) { case 0 : case 121 : case 89 : break 2 ; case 113 : case... | Pauses the scenario until the user presses a key . Useful when debugging a scenario . |
1,041 | protected function getTags ( ) { $ featureTags = $ this -> getFeature ( ) -> getTags ( ) ; $ scenarioTags = $ this -> getScenario ( ) -> getTags ( ) ; return array_unique ( array_merge ( $ featureTags , $ scenarioTags ) ) ; } | Returns all tags for the current scenario and feature . |
1,042 | public function disableMail ( $ event ) { $ tags = array_merge ( $ event -> getFeature ( ) -> getTags ( ) , $ event -> getScenario ( ) -> getTags ( ) ) ; if ( ! in_array ( 'sendmail' , $ tags ) && ! in_array ( 'sendemail' , $ tags ) ) { $ this -> getMailManager ( ) -> disableMail ( ) ; $ this -> mailCount = [ ] ; } } | By default prevent mail from being actually sent out during tests . |
1,043 | public function enableMail ( $ event ) { $ tags = array_merge ( $ event -> getFeature ( ) -> getTags ( ) , $ event -> getScenario ( ) -> getTags ( ) ) ; if ( ! in_array ( 'sendmail' , $ tags ) && ! in_array ( 'sendemail' , $ tags ) ) { $ this -> getMailManager ( ) -> enableMail ( ) ; } } | Restore mail sending . |
1,044 | public function drupalSendsMail ( TableNode $ fields ) { $ mail = [ 'body' => $ this -> getRandom ( ) -> name ( 255 ) , 'subject' => $ this -> getRandom ( ) -> name ( 20 ) , 'to' => $ this -> getRandom ( ) -> name ( 10 ) . '@anonexample.com' , 'langcode' => '' , ] ; foreach ( $ fields -> getRowsHash ( ) as $ field => $... | This is mainly useful for testing this context . |
1,045 | protected function getMailManager ( ) { if ( is_null ( $ this -> mailManager ) ) { $ this -> mailManager = new DrupalMailManager ( $ this -> getDriver ( ) ) ; } return $ this -> mailManager ; } | Get the mail manager service that handles stored test mail . |
1,046 | protected function getMail ( $ matches = [ ] , $ new = false , $ index = null , $ store = 'default' ) { $ mail = $ this -> getMailManager ( ) -> getMail ( $ store ) ; $ previousMailCount = $ this -> getMailCount ( $ store ) ; $ this -> mailCount [ $ store ] = count ( $ mail ) ; if ( $ new ) { $ mail = array_slice ( $ m... | Get collected mail matching certain specifications . |
1,047 | protected function getMailCount ( $ store ) { if ( array_key_exists ( $ store , $ this -> mailCount ) ) { $ count = $ this -> mailCount [ $ store ] ; } else { $ count = 0 ; } return $ count ; } | Get the number of mails received in a particular mail store . |
1,048 | protected function matchesMail ( $ mail = [ ] , $ matches = [ ] ) { $ matches = array_filter ( $ matches , 'strlen' ) ; foreach ( $ matches as $ field => $ value ) { if ( stripos ( $ mail [ $ field ] , $ value ) === false ) { return false ; } } return true ; } | Determine if a mail meets criteria . |
1,049 | protected function compareMail ( $ actualMail , $ expectedMail ) { $ expectedCount = count ( $ expectedMail ) ; $ this -> assertMailCount ( $ actualMail , $ expectedCount ) ; $ actualMail = $ this -> sortMail ( $ actualMail ) ; $ expectedMail = $ this -> sortMail ( $ expectedMail ) ; foreach ( $ expectedMail as $ index... | Compare actual mail with expected mail . |
1,050 | protected function assertMailCount ( $ actualMail , $ expectedCount = null ) { $ actualCount = count ( $ actualMail ) ; if ( is_null ( $ expectedCount ) ) { if ( $ actualCount === 0 ) { throw new \ Exception ( "Expected some mail, but none found." ) ; } } else { if ( $ expectedCount != $ actualCount ) { $ prettyActualM... | Assert there is the expected number of mails or that there are some mails if the exact number expected is not specified . |
1,051 | protected function sortMail ( $ mail ) { if ( count ( $ mail ) === 0 ) { return [ ] ; } foreach ( $ mail as $ key => $ row ) { if ( ! array_key_exists ( 'to' , $ row ) ) { $ mail [ $ key ] [ 'to' ] = '' ; } if ( ! array_key_exists ( 'subject' , $ row ) ) { $ mail [ $ key ] [ 'subject' ] = '' ; } if ( ! array_key_exists... | Sort mail by to subject and body . |
1,052 | public function process ( ContainerBuilder $ container ) { if ( ! $ container -> hasDefinition ( 'drupal.drupal' ) ) { return ; } $ drupalDefinition = $ container -> getDefinition ( 'drupal.drupal' ) ; foreach ( $ container -> findTaggedServiceIds ( 'drupal.driver' ) as $ id => $ attributes ) { foreach ( $ attributes a... | Register Drupal drivers . |
1,053 | public function transformVariables ( $ message ) { $ patterns = [ ] ; $ replacements = [ ] ; preg_match_all ( static :: VARIABLE_REGEX , $ message , $ matches ) ; foreach ( $ matches [ 0 ] as $ variable ) { $ replacements [ ] = $ this -> values [ $ variable ] ; $ patterns [ ] = '#' . preg_quote ( $ variable ) . '#' ; }... | Transform random variables . |
1,054 | public function beforeScenarioSetVariables ( BeforeScenarioScope $ scope ) { $ steps = [ ] ; if ( $ scope -> getFeature ( ) -> hasBackground ( ) ) { $ steps = $ scope -> getFeature ( ) -> getBackground ( ) -> getSteps ( ) ; } $ steps = array_merge ( $ steps , $ scope -> getScenario ( ) -> getSteps ( ) ) ; foreach ( $ s... | Set values for each random variable found in the current scenario . |
1,055 | protected function getCurrentScenarioTags ( StepScope $ scope ) { $ featureTags = $ scope -> getFeature ( ) -> getTags ( ) ; $ scenarioTags = $ this -> getScenario ( ) -> getTags ( ) ; return array_merge ( $ featureTags , $ scenarioTags ) ; } | Get all tags for the current scenario . |
1,056 | public function registerDriver ( $ name , DriverInterface $ driver ) { $ name = strtolower ( $ name ) ; $ this -> drivers [ $ name ] = $ driver ; } | Register a new driver . |
1,057 | public function getDriver ( $ name = null ) { $ name = strtolower ( $ name ) ? : $ this -> defaultDriverName ; if ( null === $ name ) { throw new \ InvalidArgumentException ( 'Specify a Drupal driver to get.' ) ; } if ( ! isset ( $ this -> drivers [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Drive... | Return a registered driver by name or the default driver . |
1,058 | public function assertMultipleErrors ( TableNode $ messages ) { $ this -> assertValidMessageTable ( $ messages , 'error messages' ) ; foreach ( $ messages -> getHash ( ) as $ key => $ value ) { $ value = array_change_key_case ( $ value ) ; $ message = trim ( $ value [ 'error messages' ] ) ; $ this -> assertErrorVisible... | Checks if the current page contains the given set of error messages |
1,059 | public function assertNotMultipleErrors ( TableNode $ messages ) { $ this -> assertValidMessageTable ( $ messages , 'error messages' ) ; foreach ( $ messages -> getHash ( ) as $ key => $ value ) { $ value = array_change_key_case ( $ value ) ; $ message = trim ( $ value [ 'error messages' ] ) ; $ this -> assertNotErrorV... | Checks if the current page does not contain the given set error messages |
1,060 | public function assertMultipleSuccessMessage ( TableNode $ messages ) { $ this -> assertValidMessageTable ( $ messages , 'success messages' ) ; foreach ( $ messages -> getHash ( ) as $ key => $ value ) { $ value = array_change_key_case ( $ value ) ; $ message = trim ( $ value [ 'success messages' ] ) ; $ this -> assert... | Checks if the current page contains the given set of success messages |
1,061 | public function assertNotMultipleSuccessMessage ( TableNode $ messages ) { $ this -> assertValidMessageTable ( $ messages , 'success messages' ) ; foreach ( $ messages -> getHash ( ) as $ key => $ value ) { $ value = array_change_key_case ( $ value ) ; $ message = trim ( $ value [ 'success messages' ] ) ; $ this -> ass... | Checks if the current page does not contain the given set of success messages |
1,062 | public function assertMultipleWarningMessage ( TableNode $ messages ) { $ this -> assertValidMessageTable ( $ messages , 'warning messages' ) ; foreach ( $ messages -> getHash ( ) as $ key => $ value ) { $ value = array_change_key_case ( $ value ) ; $ message = trim ( $ value [ 'warning messages' ] ) ; $ this -> assert... | Checks if the current page contains the given set of warning messages |
1,063 | public function assertNotMultipleWarningMessage ( TableNode $ messages ) { $ this -> assertValidMessageTable ( $ messages , 'warning messages' ) ; foreach ( $ messages -> getHash ( ) as $ key => $ value ) { $ value = array_change_key_case ( $ value ) ; $ message = trim ( $ value [ 'warning messages' ] ) ; $ this -> ass... | Checks if the current page does not contain the given set of warning messages |
1,064 | protected function assertValidMessageTable ( TableNode $ messages , $ expected_header ) { $ header_row = $ messages -> getRow ( 0 ) ; $ column_count = count ( $ header_row ) ; if ( $ column_count != 1 ) { throw new \ RuntimeException ( "The list of $expected_header should only contain 1 column. It has $column_count col... | Checks whether the given list of messages is valid . |
1,065 | private function assert ( $ message , $ selectorId , $ exceptionMsgNone , $ exceptionMsgMissing ) { $ selector = $ this -> getDrupalSelector ( $ selectorId ) ; $ selectorObjects = $ this -> getSession ( ) -> getPage ( ) -> findAll ( "css" , $ selector ) ; if ( empty ( $ selectorObjects ) ) { throw new ExpectationExcept... | Internal callback to check for a specific message in a given context . |
1,066 | private function assertNot ( $ message , $ selectorId , $ exceptionMsg ) { $ selector = $ this -> getDrupalSelector ( $ selectorId ) ; $ selectorObjects = $ this -> getSession ( ) -> getPage ( ) -> findAll ( "css" , $ selector ) ; if ( ! empty ( $ selectorObjects ) ) { foreach ( $ selectorObjects as $ selectorObject ) ... | Internal callback to check if the current page does not contain the given message |
1,067 | public function thereIsAnItemInTheSystemQueue ( TableNode $ table ) { $ fields = $ table -> getRowsHash ( ) ; if ( empty ( $ fields [ 'data' ] ) ) { $ fields [ 'data' ] = json_encode ( [ ] ) ; } $ query = db_insert ( 'queue' ) -> fields ( array ( 'name' => $ fields [ 'name' ] ? : user_password ( ) , 'data' => serialize... | Creates a queue item . Defaults inputs if none are available . |
1,068 | public function assertRegionButton ( $ button , $ region ) { $ regionObj = $ this -> getRegion ( $ region ) ; $ buttonObj = $ regionObj -> findButton ( $ button ) ; if ( empty ( $ buttonObj ) ) { throw new \ Exception ( sprintf ( "The button '%s' was not found in the region '%s' on the page %s" , $ button , $ region , ... | Checks if a button with id|name|title|alt|value exists in a region |
1,069 | public static function preg_match ( $ pattern , $ subject , & $ matches = null , $ flags = 0 , $ offset = 0 ) { if ( false === $ ret = preg_match ( $ pattern , $ subject , $ matches , $ flags , $ offset ) ) { switch ( preg_last_error ( ) ) { case PREG_INTERNAL_ERROR : $ error = 'Internal PCRE error.' ; break ; case PRE... | A local wrapper for preg_match which will throw a ParseException if there is an internal error in the PCRE engine . |
1,070 | protected function setNameLabels ( ) { $ this -> one = ( $ this -> data [ 'labels.has_one' ] ? $ this -> data [ 'labels.has_one' ] : ucfirst ( $ this -> name ) ) ; $ this -> many = ( $ this -> data [ 'labels.has_many' ] ? $ this -> data [ 'labels.has_many' ] : ucfirst ( $ this -> name . 's' ) ) ; $ this -> i18n = ( $ t... | Set required labels |
1,071 | protected function setLabels ( ) { if ( $ this -> data [ 'labels.overrides' ] ) { $ this -> labels = array_replace ( $ this -> labels , $ this -> data [ 'labels.overrides' ] ) ; } } | Set label overrides |
1,072 | protected function setDefaultConfig ( ) { if ( $ this -> data [ 'config' ] ) { $ this -> config = $ this -> data [ 'config' ] ; } if ( in_array ( $ this -> data [ 'type' ] , [ 'cat' , 'category' ] ) ) { $ this -> config = [ 'hierarchical' => true ] ; } if ( $ this -> data [ 'links' ] ) { $ this -> links = $ this -> dat... | Set config defaults |
1,073 | private static function parseSequence ( $ sequence , $ flags , & $ i = 0 , $ references = array ( ) ) { $ output = array ( ) ; $ len = \ strlen ( $ sequence ) ; ++ $ i ; while ( $ i < $ len ) { if ( ']' === $ sequence [ $ i ] ) { return $ output ; } if ( ',' === $ sequence [ $ i ] || ' ' === $ sequence [ $ i ] ) { ++ $... | Parses a YAML sequence . |
1,074 | private function getPathFromArray ( $ path ) { $ paths = array ( ) ; foreach ( $ path as $ unverifiedPath ) { try { if ( $ unverifiedPath [ 0 ] !== '?' ) { $ paths = array_merge ( $ paths , $ this -> getValidPath ( $ unverifiedPath ) ) ; continue ; } $ optionalPath = ltrim ( $ unverifiedPath , '?' ) ; $ paths = array_m... | Gets an array of paths |
1,075 | protected function getPath ( ) { $ default = ( file_exists ( dirname ( get_template_directory ( ) ) . '/app' ) ? dirname ( get_template_directory ( ) ) . '/app/models' : get_stylesheet_directory ( ) . '/models' ) ; $ this -> path = ( has_filter ( 'sober/models/path' ) ? apply_filters ( 'sober/models/path' , rtrim ( $ t... | Get custom path |
1,076 | protected function route ( $ config ) { if ( in_array ( $ config [ 'type' ] , [ 'post-type' , 'cpt' , 'posttype' , 'post_type' ] ) ) { ( new PostType ( $ config ) ) -> run ( ) ; } if ( in_array ( $ config [ 'type' ] , [ 'taxonomy' , 'tax' , 'category' , 'cat' , 'tag' ] ) ) { ( new Taxonomy ( $ config ) ) -> run ( ) ; }... | Route to class |
1,077 | protected function expandDottedKey ( $ data ) { foreach ( $ data as $ key => $ value ) { if ( ( $ found = strpos ( $ key , '.' ) ) !== false ) { $ newKey = substr ( $ key , 0 , $ found ) ; $ remainder = substr ( $ key , $ found + 1 ) ; $ expandedValue = $ this -> expandDottedKey ( array ( $ remainder => $ value ) ) ; i... | Expand array with dotted keys to multidimensional array |
1,078 | public function unescapeDoubleQuotedString ( $ value ) { $ callback = function ( $ match ) { return $ this -> unescapeCharacter ( $ match [ 0 ] ) ; } ; return preg_replace_callback ( '/' . self :: REGEX_ESCAPED_CHARACTER . '/u' , $ callback , $ value ) ; } | Unescapes a double quoted string . |
1,079 | protected function setDefaultLabels ( ) { $ this -> labels = [ 'name' => _x ( $ this -> many , 'Post type general name' , $ this -> i18n ) , 'singular_name' => _x ( $ this -> one , 'Post type singular name' , $ this -> i18n ) , 'menu_name' => _x ( $ this -> many , 'Admin Menu text' , $ this -> i18n ) , 'name_admin_bar'... | Set default labels |
1,080 | public function getUserAgent ( ) : string { $ userAgent = '' ; foreach ( $ this -> userAgentHeaders as $ header ) { if ( array_key_exists ( $ header , $ this -> source ) && $ this -> source [ $ header ] ) { $ userAgent = $ this -> cleanParam ( $ this -> source [ $ header ] ) ; break ; } } return $ userAgent ; } | detect the useragent |
1,081 | public static function getAllPatternCacheSubkeys ( ) : array { $ subkeys = [ ] ; $ chars = [ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' ] ; foreach ( $ chars as $ charOne ) { foreach ( $ chars as $ charTwo ) { $ subkeys [ $ charOne . $ charTwo ] = '' ; } } return $ sub... | Gets all subkeys for the pattern cache files |
1,082 | public static function getAllIniPartCacheSubKeys ( ) : array { $ subKeys = [ ] ; $ chars = [ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' ] ; foreach ( $ chars as $ charOne ) { foreach ( $ chars as $ charTwo ) { foreach ( $ chars as $ charThree ) { $ subKeys [ ] = $ char... | Gets all sub keys for the inipart cache files |
1,083 | public static function createDefaultLogger ( OutputInterface $ output ) : LoggerInterface { $ logger = new Logger ( 'browscap' ) ; $ consoleLogger = new ConsoleLogger ( $ output ) ; $ psrHandler = new PsrHandler ( $ consoleLogger ) ; $ logger -> pushHandler ( $ psrHandler ) ; $ memoryProcessor = new MemoryUsageProcesso... | creates a \ Monolog \ Logger instance |
1,084 | public function convertFile ( string $ iniFile ) : void { if ( empty ( $ iniFile ) ) { throw new FileNameMissingException ( 'the file name can not be empty' ) ; } if ( ! is_readable ( $ iniFile ) ) { throw new FileNotFoundException ( 'it was not possible to read the local file ' . $ iniFile ) ; } $ iniString = file_get... | reads and parses an ini file and writes the results into the cache |
1,085 | public function fetch ( string $ file , string $ remoteFile = IniLoaderInterface :: PHP_INI ) : void { try { $ cachedVersion = $ this -> checkUpdate ( ) ; } catch ( NoNewVersionException $ e ) { return ; } catch ( NoCachedVersionException $ e ) { $ cachedVersion = 0 ; } $ this -> logger -> debug ( 'started fetching rem... | fetches a remote file and stores it into a local folder |
1,086 | public function update ( string $ remoteFile = IniLoaderInterface :: PHP_INI ) : void { $ this -> logger -> debug ( 'started fetching remote file' ) ; try { $ cachedVersion = $ this -> checkUpdate ( ) ; } catch ( NoNewVersionException $ e ) { return ; } catch ( NoCachedVersionException $ e ) { $ cachedVersion = 0 ; } $... | fetches a remote file parses it and writes the result into the cache if the local stored information are in the same version as the remote data no actions are taken |
1,087 | public function checkUpdate ( ) : ? int { $ success = null ; try { $ cachedVersion = $ this -> cache -> getItem ( 'browscap.version' , false , $ success ) ; } catch ( InvalidArgumentException $ e ) { throw new ErrorCachedVersionException ( 'an error occured while reading the data version from the cache' , 0 , $ e ) ; }... | checks if an update on a remote location for the local file or the cache |
1,088 | public function createIniParts ( string $ content ) : \ Generator { preg_match_all ( '/(?<=\[)(?:[^\r\n]+)(?=\])/m' , $ content , $ patternPositions ) ; $ patternPositions = $ patternPositions [ 0 ] ; $ iniParts = preg_split ( '/\[[^\r\n]+\]/' , $ content ) ; if ( false === $ iniParts ) { throw new \ UnexpectedValueExc... | Creates new ini part cache files |
1,089 | public function setRemoteFilename ( string $ name ) : void { if ( empty ( $ name ) ) { throw new Exception ( 'the filename can not be empty' , Exception :: INI_FILE_MISSING ) ; } $ this -> remoteFilename = $ name ; } | sets the name of the local ini file |
1,090 | public function getParser ( ) : ParserInterface { if ( null === $ this -> parser ) { $ patternHelper = new Parser \ Helper \ GetPattern ( $ this -> cache , $ this -> logger ) ; $ dataHelper = new Parser \ Helper \ GetData ( $ this -> cache , $ this -> logger , new Quoter ( ) ) ; $ this -> parser = new Parser \ Ini ( $ ... | returns an instance of the used parser class |
1,091 | public function getBrowser ( string $ userAgent = null ) : \ stdClass { if ( null === $ this -> cache -> getVersion ( ) ) { throw new Exception ( 'there is no active cache available, please use the BrowscapUpdater and run the update command' ) ; } if ( ! is_string ( $ userAgent ) ) { $ support = new Helper \ Support ( ... | parses the given user agent to get the information about the browser |
1,092 | public function pregUnQuote ( string $ pattern ) : string { if ( ! preg_match ( '/[^a-z\s]/i' , $ pattern ) ) { return $ pattern ; } $ origPattern = $ pattern ; $ pattern = preg_replace ( [ '/(?<!\\\\)\\.\\*/' , '/(?<!\\\\)\\./' , '/(?<!\\\\)\\\\x/' ] , [ '\\*' , '\\?' , '\\x' ] , $ pattern ) ; if ( null === $ pattern ... | Reverts the quoting of a pattern . |
1,093 | protected function askEmail ( ) { $ email = $ this -> ask ( 'E-mail' ) ; if ( ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { $ this -> error ( "'$email' is not an email address." ) ; exit ( 2 ) ; } elseif ( UserProxy :: where ( 'email' , $ email ) -> first ( ) ) { $ this -> error ( "User '$email' already exists" ... | Asks for and validates E - mail address |
1,094 | public function registerEnumIcons ( $ enumClass , array $ icons ) { $ this -> map = array_merge ( $ this -> map , [ shorten ( $ enumClass ) => $ icons ] ) ; } | Register icon mapping for a specific enum class |
1,095 | public function icon ( Enum $ enum ) { return array_get ( $ this -> map , sprintf ( '%s.%s' , shorten ( get_class ( $ enum ) ) , $ enum -> value ( ) ) , config ( 'konekt.app_shell.icon.default' , 'default' ) ) ; } | Returns the icon for the given enum instance |
1,096 | protected function registerThirdPartyProviders ( ) { if ( 'testing' == $ this -> app -> environment ( ) || version_compare ( Application :: VERSION , '5.5.0' , '<' ) ) { $ this -> registerMenuComponent ( ) ; $ this -> registerFormComponent ( ) ; $ this -> registerFlashComponent ( ) ; $ this -> registerBreadcrumbsCompon... | Registers 3rd party providers AppShell is built on top of |
1,097 | protected function initializeMenus ( ) { foreach ( $ this -> config ( 'menu' ) as $ name => $ config ) { Menu :: create ( $ name , $ config ) ; } if ( $ appshellMenu = Menu :: get ( 'appshell' ) ) { $ crm = $ appshellMenu -> addItem ( 'crm_group' , __ ( 'CRM' ) ) ; $ crm -> addSubItem ( 'customers' , __ ( 'Customers' )... | Initializes menus set in the configuration |
1,098 | private function registerFormComponent ( ) { $ this -> app -> register ( \ Collective \ Html \ HtmlServiceProvider :: class ) ; $ this -> concord -> registerAlias ( 'Form' , \ Collective \ Html \ FormFacade :: class ) ; $ this -> concord -> registerAlias ( 'Html' , \ Collective \ Html \ HtmlFacade :: class ) ; } | Register Laravel Collective Form Component |
1,099 | private function registerMenuComponent ( ) { $ this -> app -> register ( \ Konekt \ Menu \ MenuServiceProvider :: class ) ; $ this -> concord -> registerAlias ( 'Menu' , \ Konekt \ Menu \ Facades \ Menu :: class ) ; } | Registers Konekt Menu Component |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.