idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
5,300
public function syncDbAllSites ( ) { $ exit_code = 0 ; $ multisites = $ this -> getConfigValue ( 'multisites' ) ; $ this -> printSyncMap ( $ multisites ) ; $ continue = $ this -> confirm ( "Continue?" ) ; if ( ! $ continue ) { return $ exit_code ; } foreach ( $ multisites as $ multisite ) { $ this -> say ( "Refreshing ...
Iteratively copies remote db to local db for each multisite .
5,301
public function syncDb ( ) { $ local_alias = '@' . $ this -> getConfigValue ( 'drush.aliases.local' ) ; $ remote_alias = '@' . $ this -> getConfigValue ( 'drush.aliases.remote' ) ; $ task = $ this -> taskDrush ( ) -> alias ( '' ) -> drush ( 'cache-clear drush' ) -> drush ( 'sql-sync' ) -> arg ( $ remote_alias ) -> arg ...
Copies remote db to local db for default site .
5,302
public function toggleModules ( ) { if ( $ this -> input ( ) -> hasArgument ( 'environment' ) ) { $ environment = $ this -> input ( ) -> getArgument ( 'environment' ) ; } elseif ( $ this -> getConfig ( ) -> has ( 'environment' ) ) { $ environment = $ this -> getConfigValue ( 'environment' ) ; } elseif ( ! empty ( $ _EN...
Enables and uninstalls specified modules .
5,303
protected function doToggleModules ( $ command , $ config_key ) { if ( $ this -> getConfig ( ) -> has ( $ config_key ) ) { $ this -> say ( "Executing <comment>drush $command</comment> for modules defined in <comment>$config_key</comment>..." ) ; $ modules = ( array ) $ this -> getConfigValue ( $ config_key ) ; $ module...
Enables or uninstalls an array of modules .
5,304
public function interactExecuteOnHost ( ) { if ( ! $ this -> getInspector ( ) -> isVmCli ( ) && $ this -> getInspector ( ) -> isDrupalVmLocallyInitialized ( ) && $ this -> getConfigValue ( 'vm.blt-in-vm' ) ) { $ this -> logger -> warning ( "Drupal VM is locally initialized, but you are not inside the VM." ) ; $ this ->...
Ask whether user would like to execute on host machine .
5,305
public function travisInit ( ) { $ result = $ this -> taskFilesystemStack ( ) -> copy ( $ this -> getConfigValue ( 'blt.root' ) . '/scripts/travis/.travis.yml' , $ this -> getConfigValue ( 'repo.root' ) . '/.travis.yml' , TRUE ) -> stopOnFail ( ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBO...
Initializes default Travis CI configuration for this project .
5,306
public function gitlabInit ( ) { $ result = $ this -> taskFilesystemStack ( ) -> copy ( $ this -> getConfigValue ( 'blt.root' ) . '/scripts/gitlab/gitlab-ci.yml' , $ this -> getConfigValue ( 'repo.root' ) . '/.gitlab-ci.yml' , TRUE ) -> stopOnFail ( ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_...
Initializes default GitLab Pipelines configuration for this project .
5,307
public static function mungeFiles ( $ file1 , $ file2 ) { $ default_contents = [ ] ; $ file1_contents = ( array ) json_decode ( file_get_contents ( $ file1 ) , TRUE ) + $ default_contents ; $ file2_contents = ( array ) json_decode ( file_get_contents ( $ file2 ) , TRUE ) + $ default_contents ; $ output = self :: mergeK...
Selectively merges parts of two composer . json files .
5,308
protected static function mergeKeyed ( $ file1_contents , $ file2_contents , $ exclude_keys = [ ] ) { $ merge_keys = [ 'config' , 'extra' , ] ; $ output = $ file1_contents ; foreach ( $ merge_keys as $ key ) { if ( ! array_key_exists ( $ key , $ file1_contents ) ) { $ file1_contents [ $ key ] = [ ] ; } if ( ! array_key...
Merges specific keyed arrays and objects in composer . json files .
5,309
public function lintFileSets ( ) { $ this -> say ( "Validating twig syntax for all custom modules and themes..." ) ; $ fileset_manager = $ this -> getContainer ( ) -> get ( 'filesetManager' ) ; $ fileset_ids = $ this -> getConfigValue ( 'validate.twig.filesets' ) ; $ filesets = $ fileset_manager -> getFilesets ( $ file...
Executes Twig validator against all validate . twig . filesets files .
5,310
public function lintFileList ( $ file_list ) { $ this -> say ( "Linting twig files..." ) ; $ files = explode ( "\n" , $ file_list ) ; $ fileset_manager = $ this -> getContainer ( ) -> get ( 'filesetManager' ) ; $ fileset_ids = $ this -> getConfigValue ( 'validate.twig.filesets' ) ; $ filesets = $ fileset_manager -> get...
Executes Twig validator against a list of files if in twig . filesets .
5,311
protected function executeTwigLintCommandAgainstFilesets ( array $ filesets ) { $ command = $ this -> createTwigLintCommand ( ) ; $ application = $ this -> getContainer ( ) -> get ( 'application' ) ; $ application -> add ( $ command ) ; $ passed = TRUE ; $ failed_filesets = [ ] ; foreach ( $ filesets as $ fileset_id =>...
Lints twig against multiple filesets .
5,312
protected function createTwigLintCommand ( ) { $ twig = new Environment ( new FilesystemLoader ( ) ) ; $ repo_root = $ this -> getConfigValue ( 'repo.root' ) ; $ extension_file_contents = file_get_contents ( $ repo_root . '/docroot/core/lib/Drupal/Core/Template/TwigExtension.php' ) ; $ twig_filters = ( array ) $ this -...
Creates the Twig lint command .
5,313
public function wizardGenerateSettingsFiles ( ) { $ missing = FALSE ; if ( ! $ this -> getInspector ( ) -> isDrupalLocalSettingsFilePresent ( ) ) { $ this -> logger -> warning ( "<comment>{$this->getConfigValue('drupal.local_settings_file')}</comment> is missing." ) ; $ missing = TRUE ; } elseif ( ! $ this -> getInspec...
Wizard for generating setup files .
5,314
public function wizardInstallDrupal ( ) { if ( ! $ this -> getInspector ( ) -> isMySqlAvailable ( ) ) { return FALSE ; } if ( ! $ this -> getInspector ( ) -> isDrupalInstalled ( ) ) { $ this -> logger -> warning ( 'Drupal is not installed.' ) ; $ confirm = $ this -> confirm ( "Do you want to install Drupal?" ) ; if ( $...
Wizard for installing Drupal .
5,315
public function isDrupalInstalled ( ) { $ this -> logger -> debug ( "Verifying that Drupal is installed..." ) ; $ result = $ this -> executor -> drush ( "sqlq \"SHOW TABLES LIKE 'config'\"" ) -> run ( ) ; $ output = trim ( $ result -> getMessage ( ) ) ; $ installed = $ result -> wasSuccessful ( ) && $ output == 'config...
Checks that Drupal is installed caches result .
5,316
public function getDrushStatus ( ) { $ status_info = ( array ) json_decode ( $ this -> executor -> drush ( 'status --format=json --fields=*' ) -> run ( ) -> getMessage ( ) , TRUE ) ; return $ status_info ; }
Gets the result of drush status .
5,317
public function isDrushAliasValid ( $ alias ) { $ bin = $ this -> getConfigValue ( 'composer.bin' ) ; $ command = "'$bin/drush' site:alias @$alias --format=json" ; return $ this -> executor -> execute ( $ command ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERY_VERBOSE ) -> run ( ) -> wasSucce...
Validates a drush alias .
5,318
public function getDrushMajorVersion ( ) { $ version_info = json_decode ( $ this -> executor -> drush ( 'version --format=json' ) -> run ( ) -> getMessage ( ) , TRUE ) ; if ( ! empty ( $ version_info [ 'drush-version' ] ) ) { $ version = $ version_info [ 'drush-version' ] ; } else { $ version = $ version_info ; } $ maj...
Gets the major version of drush .
5,319
public function isMySqlAvailable ( ) { if ( is_null ( $ this -> isMySqlAvailable ) ) { $ this -> isMySqlAvailable = $ this -> getMySqlAvailable ( ) ; } return $ this -> isMySqlAvailable ; }
Determines if MySQL is available caches result .
5,320
public function getMySqlAvailable ( ) { $ this -> logger -> debug ( "Verifying that MySQL is available..." ) ; $ result = $ this -> executor -> drush ( "sqlq \"SHOW DATABASES\"" ) -> run ( ) ; return $ result -> wasSuccessful ( ) ; }
Determines if MySQL is available . Uses MySQL credentials from Drush .
5,321
public function isDrupalVmLocallyInitialized ( ) { if ( is_null ( $ this -> isDrupalVmLocallyInitialized ) ) { $ this -> isDrupalVmLocallyInitialized = $ this -> isVmCli ( ) || $ this -> getConfigValue ( 'vm.enable' ) ; $ statement = $ this -> isDrupalVmLocallyInitialized ? "is" : "is not" ; $ this -> logger -> debug (...
Determines if Drupal VM is initialized for the local machine .
5,322
public function isDrupalVmConfigValid ( ) { $ valid = TRUE ; $ status = $ this -> getDrupalVmStatus ( ) ; $ machine_name = $ this -> getConfigValue ( 'project.machine_name' ) ; if ( empty ( $ status [ $ machine_name ] [ 'state' ] ) ) { $ this -> logger -> error ( "Could not find VM. Please ensure that the VM machine na...
Determines if Drupal VM config is valid .
5,323
public function isDrupalVmBooted ( ) { if ( ! $ this -> commandExists ( 'vagrant' ) ) { $ this -> isDrupalVmBooted = FALSE ; } if ( is_null ( $ this -> isDrupalVmBooted ) ) { $ status = $ this -> getDrupalVmStatus ( ) ; $ machine_name = $ this -> getConfigValue ( 'project.machine_name' ) ; $ this -> isDrupalVmBooted = ...
Determines if Drupal VM is booted .
5,324
public function isVagrantPluginInstalled ( $ plugin ) { $ installed = ( bool ) $ this -> executor -> execute ( "vagrant plugin list | grep '$plugin'" ) -> interactive ( FALSE ) -> silent ( TRUE ) -> run ( ) -> getMessage ( ) ; return $ installed ; }
Checks to see if a given vagrant plugin is installed .
5,325
public function getComposerVersion ( ) { $ version = $ this -> executor -> execute ( "composer --version" ) -> interactive ( FALSE ) -> silent ( TRUE ) -> run ( ) -> getMessage ( ) ; return $ version ; }
Gets Composer version .
5,326
public function isBltAliasInstalled ( ) { $ cli_config_file = $ this -> getCliConfigFile ( ) ; if ( ! is_null ( $ cli_config_file ) && file_exists ( $ cli_config_file ) ) { $ contents = file_get_contents ( $ cli_config_file ) ; if ( strstr ( $ contents , 'function blt' ) ) { return TRUE ; } } return FALSE ; }
Checks to see if BLT alias is installed on CLI .
5,327
public function getCliConfigFile ( ) { $ file = NULL ; if ( DIRECTORY_SEPARATOR == '\\' ) { $ user = $ _SERVER [ 'USERNAME' ] ; $ home_dir = $ _SERVER [ 'USERPROFILE' ] ; } else { $ user = posix_getpwuid ( posix_getuid ( ) ) ; $ home_dir = $ user [ 'dir' ] ; } if ( strstr ( getenv ( 'SHELL' ) , 'zsh' ) ) { $ file = $ h...
Determines the CLI config file .
5,328
public function isGitMinimumVersionSatisfied ( $ minimum_version ) { exec ( "git --version | cut -d' ' -f3" , $ output , $ exit_code ) ; if ( version_compare ( $ output [ 0 ] , $ minimum_version , '>=' ) ) { return TRUE ; } return FALSE ; }
Verifies that installed minimum git version is met .
5,329
public function getLocalBehatConfig ( ) { $ behat_local_config_file = $ this -> getConfigValue ( 'repo.root' ) . '/tests/behat/local.yml' ; $ behat_local_config = new BltConfig ( ) ; $ loader = new YamlConfigLoader ( ) ; $ processor = new YamlConfigProcessor ( ) ; $ processor -> extend ( $ loader -> load ( $ behat_loca...
Gets the local behat configuration defined in local . yml .
5,330
public function filesExist ( $ files ) { foreach ( $ files as $ file ) { if ( ! file_exists ( $ file ) ) { $ this -> logger -> warning ( "Required file $file does not exist." ) ; return FALSE ; } } return TRUE ; }
Determines if all file in a given array exist .
5,331
public function isBehatConfigured ( ) { $ local_behat_config = $ this -> getLocalBehatConfig ( ) ; if ( $ this -> getConfigValue ( 'project.local.uri' ) != $ local_behat_config -> get ( 'local.extensions.Behat\MinkExtension.base_url' ) ) { $ this -> logger -> warning ( 'project.local.uri in blt.yml does not match local...
Determines if Behat is properly configured on the local machine .
5,332
public function getCurrentSchemaVersion ( ) { if ( file_exists ( $ this -> getConfigValue ( 'blt.config-files.schema-version' ) ) ) { $ version = trim ( file_get_contents ( $ this -> getConfigValue ( 'blt.config-files.schema-version' ) ) ) ; } else { $ version = $ this -> getContainer ( ) -> get ( 'updater' ) -> getLat...
Gets the current schema version of the root project .
5,333
protected function warnIfDrupalVmNotRunning ( ) { if ( ! $ this -> isVmCli ( ) && $ this -> isDrupalVmLocallyInitialized ( ) && ! $ this -> isDrupalVmBooted ( ) ) { $ this -> logger -> warning ( "Drupal VM is locally initialized, but is not running." ) ; } }
Emits a warning if Drupal VM is initialized but not running .
5,334
public function isActiveConfigIdentical ( ) { $ uri = $ this -> getConfigValue ( 'drush.uri' ) ; $ result = $ this -> executor -> drush ( "config:status --uri=$uri 2>&1" ) -> run ( ) ; $ message = trim ( $ result -> getMessage ( ) ) ; $ identical = strstr ( $ message , 'No differences between DB and sync directory' ) !...
Determines if the active config is identical to sync directory .
5,335
public function drush ( $ command ) { $ this -> setOptionsForLastCommand ( ) ; if ( ! $ this -> defaultsInitialized ) { $ this -> init ( ) ; } if ( is_array ( $ command ) ) { $ command = implode ( ' ' , array_filter ( $ command ) ) ; } $ this -> commands [ ] = trim ( $ command ) ; return $ this ; }
Adds the given drush command to a stack .
5,336
protected function init ( ) { if ( $ this -> getConfig ( ) -> get ( 'drush.bin' ) ) { $ this -> executable = str_replace ( ' ' , '\\ ' , $ this -> getConfig ( ) -> get ( 'drush.bin' ) ) ; } else { $ this -> executable = 'drush' ; } if ( ! isset ( $ this -> dir ) ) { $ this -> dir ( $ this -> getConfig ( ) -> get ( 'dru...
Sets up drush defaults using config .
5,337
protected function mixedToBool ( $ mixedVar ) { if ( is_string ( $ mixedVar ) ) { $ boolVar = ( $ mixedVar === 'yes' || $ mixedVar === 'true' ) ; } else { $ boolVar = ( bool ) $ mixedVar ; } return $ boolVar ; }
Helper function to get the boolean equivalent of a variable .
5,338
protected function setOptionsForLastCommand ( ) { if ( isset ( $ this -> commands ) ) { $ numberOfCommands = count ( $ this -> commands ) ; $ correspondingCommand = $ numberOfCommands - 1 ; $ this -> options [ $ correspondingCommand ] = $ this -> arguments ; $ this -> arguments = '' ; } elseif ( isset ( $ this -> argum...
Associates arguments with their corresponding drush command .
5,339
protected function setGlobalOptions ( ) { if ( isset ( $ this -> uri ) && ! empty ( $ this -> uri ) ) { $ this -> option ( 'uri' , $ this -> uri ) ; } if ( ! $ this -> interactive ) { $ this -> option ( 'no-interaction' ) ; } if ( $ this -> verbose !== FALSE ) { $ verbosity_threshold = $ this -> verbosityThreshold ( ) ...
Set the options to be used for each drush command in the stack .
5,340
protected function setupExecution ( ) { $ this -> setOptionsForLastCommand ( ) ; $ this -> setGlobalOptions ( ) ; $ globalOptions = $ this -> arguments ; foreach ( $ this -> commands as $ commandNumber => $ command ) { if ( $ this -> alias ) { $ command = "@{$this->alias} {$command}" ; } $ options = isset ( $ this -> o...
Adds drush commands with their corresponding options to stack .
5,341
protected function checkFileSystem ( ) { $ paths = [ '%files' => 'Public files directory' , '%private' => 'Private files directory' , '%temp' => 'Temporary files directory' , ] ; foreach ( $ paths as $ key => $ title ) { if ( empty ( $ this -> drushStatus [ '%paths' ] [ $ key ] ) ) { $ this -> logProblem ( __FUNCTION__...
Checks that configured file system paths exist and are writable .
5,342
public function phpcbfFileSet ( ) { $ this -> say ( 'Fixing and beautifying code...' ) ; $ bin = $ this -> getConfigValue ( 'composer.bin' ) ; $ result = $ this -> taskExec ( "$bin/phpcbf" ) -> dir ( $ this -> getConfigValue ( 'repo.root' ) ) -> run ( ) ; $ exit_code = $ result -> getExitCode ( ) ; switch ( $ exit_code...
Fixes and beautifies custom code according to Drupal Coding standards .
5,343
public function get ( $ key ) { $ out = NULL ; $ path = $ this -> getFileName ( $ key ) ; if ( file_exists ( $ path ) ) { $ out = file_get_contents ( $ path ) ; $ out = json_decode ( $ out , TRUE ) ; } return $ out ; }
Reads retrieves data from the store .
5,344
public function set ( $ key , $ data ) { $ path = $ this -> getFileName ( $ key , TRUE ) ; file_put_contents ( $ path , json_encode ( $ data ) ) ; }
Saves a value with the given key .
5,345
public function remove ( $ key ) { $ path = $ this -> getFileName ( $ key , TRUE ) ; if ( file_exists ( $ path ) ) { unlink ( $ path ) ; } }
Remove value from the store .
5,346
public function keys ( ) { $ root = $ this -> directory ; if ( file_exists ( $ root ) && is_readable ( $ root ) ) { return array_diff ( scandir ( $ root ) , array ( '..' , '.' ) ) ; } return [ ] ; }
Return a list of all keys in the store .
5,347
protected function getFileName ( $ key , $ writable = FALSE ) { $ key = $ this -> cleanKey ( $ key ) ; if ( $ writable ) { $ this -> ensureDirectoryWritable ( ) ; } if ( ! $ key ) { throw new BltException ( 'Could not save data to a file because it is missing an ID' ) ; } return $ this -> directory . '/' . $ key ; }
Get a valid file name for the given key .
5,348
protected function ensureDirectoryWritable ( ) { if ( ! $ this -> directory ) { throw new BltException ( 'Could not save data to a file because the path setting is mis-configured.' ) ; } $ writable = is_dir ( $ this -> directory ) || ( ! file_exists ( $ this -> directory ) && @ mkdir ( $ this -> directory , 0777 , TRUE...
Check that the directory is writable and create it if we can .
5,349
public function installBltAlias ( ) { if ( isset ( $ _SERVER [ 'ComSpec' ] ) ) { $ bltRoot = $ this -> getConfigValue ( 'blt.root' ) . '\\vendor\\bin' ; $ this -> logger -> error ( "Setting a blt alias is not supported in cmd.exe" ) ; $ this -> say ( "<info>Please use Windows to add <comment>$bltRoot</comment> to your ...
Installs the BLT alias for command line usage .
5,350
protected function createNewAlias ( ) { $ this -> say ( "Installing <comment>blt</comment> alias..." ) ; $ config_file = $ this -> getInspector ( ) -> getCliConfigFile ( ) ; if ( is_null ( $ config_file ) ) { $ this -> logger -> error ( "Could not install blt alias. No profile found. Tried ~/.zshrc, ~/.bashrc, ~/.bash_...
Creates a new BLT alias in appropriate CLI config file .
5,351
protected function getAliasInfo ( ) { $ alias_length = NULL ; $ alias = NULL ; $ config_file = $ this -> getInspector ( ) -> getCliConfigFile ( ) ; $ contents = file_get_contents ( $ config_file ) ; $ needle = 'function blt() {' ; $ begin_alias_pos = strpos ( $ contents , $ needle ) ; $ end_alias_pos = $ this -> getClo...
Gets information about the installed BLT alias .
5,352
protected function updateAlias ( ) { $ alias_info = $ this -> getAliasInfo ( ) ; $ new_contents = str_replace ( $ alias_info [ 'alias' ] , $ alias_info [ 'canonical_alias' ] , $ alias_info [ 'contents' ] ) ; $ bytes = file_put_contents ( $ alias_info [ 'config_file' ] , $ new_contents ) ; if ( ! $ bytes ) { throw new B...
Replaces installed alias with up - to - date alias .
5,353
protected function getClosingBracketPosition ( $ contents , $ start_pos ) { $ brackets = [ '{' ] ; for ( $ pos = $ start_pos ; $ pos < strlen ( $ contents ) ; $ pos ++ ) { $ char = substr ( $ contents , $ pos , 1 ) ; if ( $ char == '{' ) { array_push ( $ brackets , $ char ) ; } elseif ( $ char == '}' ) { array_pop ( $ ...
Find the position of a closing bracket for a given stanza in a string .
5,354
public function skipDisabledCommands ( ConsoleCommandEvent $ event ) { $ command = $ event -> getCommand ( ) ; if ( $ this -> isCommandDisabled ( $ command -> getName ( ) ) ) { $ event -> disableCommand ( ) ; } }
Disable any command listed in the disable - target config key .
5,355
public function sniffFileSets ( ) { $ bin = $ this -> getConfigValue ( 'composer.bin' ) ; $ result = $ this -> taskExecStack ( ) -> dir ( $ this -> getConfigValue ( 'repo.root' ) ) -> exec ( "$bin/phpcs" ) -> run ( ) ; $ exit_code = $ result -> getExitCode ( ) ; if ( $ exit_code ) { if ( $ this -> input ( ) -> isIntera...
Executes PHP Code Sniffer against all phpcs . filesets files .
5,356
public function sniffFileList ( $ file_list ) { $ this -> say ( "Sniffing directories containing changed files..." ) ; $ files = explode ( "\n" , $ file_list ) ; $ files = array_filter ( $ files ) ; if ( $ files ) { $ temp_path = $ this -> getConfigValue ( 'repo.root' ) . '/tmp/phpcs-fileset' ; $ this -> taskWriteToFil...
Executes PHP Code Sniffer against a list of files if in phpcs . filesets .
5,357
public function printPreamble ( ) { $ this -> logger -> notice ( "This command will initialize support for Acquia Cloud Site Factory by performing the following tasks:" ) ; $ this -> logger -> notice ( " * Adding drupal/acsf and acquia/acsf-tools the require array in your composer.json file." ) ; $ this -> logger -> n...
Prints information about the command .
5,358
public function acsfInitialize ( $ options = [ 'acsf-version' => '^2.47.0' ] ) { $ this -> printPreamble ( ) ; $ this -> acsfHooksInitialize ( ) ; $ this -> say ( 'Adding acsf module as a dependency...' ) ; $ package_options = [ 'package_name' => 'drupal/acsf' , 'package_version' => $ options [ 'acsf-version' ] , ] ; $...
Initializes ACSF support for project .
5,359
public function acsfDrushInitialize ( ) { $ this -> say ( 'Executing initialization command provided acsf module...' ) ; $ acsf_include = $ this -> getConfigValue ( 'docroot' ) . '/modules/contrib/acsf/acsf_init' ; $ result = $ this -> taskExecStack ( ) -> exec ( $ this -> getConfigValue ( 'repo.root' ) . "/vendor/bin/...
Refreshes the ACSF settings and hook files .
5,360
protected function downloadDrush8 ( $ destination ) { $ file = fopen ( $ destination , 'w' ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , 'https://github.com/drush-ops/drush/releases/download/8.1.15/drush.phar' ) ; curl_setopt ( $ ch , CURLOPT_FAILONERROR , TRUE ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOC...
Download drush 8 binary .
5,361
public function composerInstall ( ) { $ result = $ this -> taskExec ( ( DIRECTORY_SEPARATOR == "\\" ) ? 'set' : 'export' . " COMPOSER_EXIT_ON_PATCH_FAILURE=1 && composer install --ansi --no-interaction --optimize-autoloader --apcu-autoloader" ) -> dir ( $ this -> getConfigValue ( 'repo.root' ) ) -> interactive ( $ this...
Installs Composer dependencies .
5,362
public static function expandFromDotNotatedKeys ( array $ array ) { $ data = new Data ( ) ; foreach ( $ array as $ key => $ value ) { $ data -> set ( $ key , $ value ) ; } return $ data -> export ( ) ; }
Converts dot - notated keys to proper associative nested keys .
5,363
public static function flattenMultidimensionalArray ( array $ array , $ glue ) { $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveArrayIterator ( $ array ) ) ; $ result = array ( ) ; foreach ( $ iterator as $ leafValue ) { $ keys = array ( ) ; foreach ( range ( 0 , $ iterator -> getDepth ( ) ) as $ depth )...
Flattens a multidimensional array to a flat array using custom glue .
5,364
public static function convertArrayToFlatTextArray ( array $ array ) { $ rows = [ ] ; $ max_line_length = 60 ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ flattened_array = self :: flattenToDotNotatedKeys ( $ value ) ; foreach ( $ flattened_array as $ sub_key => $ sub_value ) { if ( $ sub_...
Converts a multi - dimensional array to a human - readable flat array .
5,365
public function getValue ( $ key ) { if ( ! $ this -> getConfig ( ) -> has ( $ key ) ) { throw new BltException ( "$key is not set." ) ; } $ this -> say ( $ this -> getConfigValue ( $ key ) ) ; }
Gets the value of a config variable .
5,366
public function dump ( ) { $ config = $ this -> getConfig ( ) -> export ( ) ; ksort ( $ config ) ; $ this -> printArrayAsTable ( $ config ) ; }
Dumps all configuration values .
5,367
public static function mungeFiles ( $ file1 , $ file2 ) { $ file1_contents = ( array ) self :: parseFile ( $ file1 ) ; $ file2_contents = ( array ) self :: parseFile ( $ file2 ) ; return self :: arrayMergeRecursiveExceptEmpty ( $ file1_contents , $ file2_contents ) ; }
Merges the arrays in two yaml files .
5,368
public static function arrayMergeRecursiveExceptEmpty ( array & $ array1 , array & $ array2 ) { $ merged = $ array1 ; foreach ( $ array2 as $ key => & $ value ) { if ( is_array ( $ value ) && isset ( $ merged [ $ key ] ) && is_array ( $ merged [ $ key ] ) && ! empty ( $ value ) ) { $ merged [ $ key ] = self :: arrayMer...
Recursively merges arrays UNLESS second array is empty .
5,369
public function validateAcsf ( ) { $ this -> say ( "Validating ACSF settings..." ) ; $ task = $ this -> taskDrush ( ) -> stopOnFail ( ) -> drush ( "--include=modules/contrib/acsf/acsf_init acsf-init-verify" ) ; $ result = $ task -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Failed to v...
Executes the acsf - init - validate command .
5,370
protected function installGitHook ( $ hook ) { $ fs = new Filesystem ( ) ; $ project_hook_directory = $ this -> getConfigValue ( 'repo.root' ) . "/.git/hooks" ; $ project_hook = $ project_hook_directory . "/$hook" ; if ( $ this -> getConfigValue ( 'git.hooks.' . $ hook ) ) { $ this -> say ( "Installing $hook git hook.....
Installs a given git hook .
5,371
public function update ( ) { $ task = $ this -> taskDrush ( ) -> stopOnFail ( ) -> drush ( "updb" ) ; $ result = $ task -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Failed to execute database updates!" ) ; } $ this -> invokeCommands ( [ 'drupal:config:import' , 'drupal:toggle:modules'...
Update current database to reflect the state of the Drupal file system .
5,372
public function import ( ) { $ strategy = $ this -> getConfigValue ( 'cm.strategy' ) ; if ( $ strategy != 'none' ) { $ cm_core_key = $ this -> getConfigValue ( 'cm.core.key' ) ; $ this -> logConfig ( $ this -> getConfigValue ( 'cm' ) , 'cm' ) ; $ task = $ this -> taskDrush ( ) ; $ this -> invokeHook ( 'pre-config-impor...
Imports configuration from the config directory according to cm . strategy .
5,373
protected function importConfigSplit ( $ task , $ cm_core_key ) { $ task -> drush ( "pm-enable" ) -> arg ( 'config_split' ) ; $ task -> drush ( "config-import" ) -> arg ( $ cm_core_key ) ; $ task -> drush ( "config-import" ) -> arg ( $ cm_core_key ) ; }
Import configuration using config_split module .
5,374
protected function importFeatures ( $ task , $ cm_core_key ) { $ task -> drush ( "config-import" ) -> arg ( $ cm_core_key ) -> option ( 'partial' ) ; $ task -> drush ( "pm-enable" ) -> arg ( 'features' ) ; $ task -> drush ( "cc" ) -> arg ( 'drush' ) ; if ( $ this -> getConfig ( ) -> has ( 'cm.features.bundle' ) ) { for...
Import configuration using features module .
5,375
protected function checkFeaturesOverrides ( ) { if ( $ this -> getConfigValue ( 'cm.features.no-overrides' ) ) { $ this -> say ( "Checking for features overrides..." ) ; if ( $ this -> getConfig ( ) -> has ( 'cm.features.bundle' ) ) { $ task = $ this -> taskDrush ( ) -> stopOnFail ( ) ; foreach ( $ this -> getConfigVal...
Checks whether features are overridden .
5,376
protected function getExportedSiteUuid ( $ cm_core_key ) { $ site_config_file = $ this -> getConfigValue ( 'docroot' ) . '/' . $ this -> getConfigValue ( "cm.core.dirs.$cm_core_key.path" ) . '/system.site.yml' ; if ( file_exists ( $ site_config_file ) ) { $ site_config = Yaml :: parseFile ( $ site_config_file ) ; $ sit...
Returns the site UUID stored in exported configuration .
5,377
public function linkComposer ( $ options = [ 'blt-path' => InputOption :: VALUE_REQUIRED ] ) { $ composer_json_filepath = $ this -> getConfigValue ( 'repo.root' ) . '/composer.json' ; $ composer_json = json_decode ( file_get_contents ( $ composer_json_filepath ) ) ; $ composer_json -> repositories -> blt = [ 'type' => ...
Links to a local BLT package via a Composer path repository .
5,378
public function validateSettingsFileIsValid ( CommandData $ commandData ) { if ( ! $ this -> getInspector ( ) -> isDrupalSettingsFilePresent ( ) ) { throw new BltException ( "Could not find settings.php for this site." ) ; } if ( ! $ this -> getInspector ( ) -> isDrupalSettingsFileValid ( ) ) { throw new BltException (...
Checks active settings . php file .
5,379
public function validateVmConfig ( ) { if ( $ this -> getInspector ( ) -> isDrupalVmLocallyInitialized ( ) && $ this -> getInspector ( ) -> isDrupalVmBooted ( ) && ! $ this -> getInspector ( ) -> isDrupalVmConfigValid ( ) ) { throw new BltException ( "Drupal VM configuration is invalid." ) ; } }
Validates that current PHP process is being executed inside of the VM .
5,380
public function validateGitConfig ( ) { if ( ! $ this -> getInspector ( ) -> isGitMinimumVersionSatisfied ( '2.0' ) ) { throw new BltException ( "Your system does not meet BLT's requirements. Please update git to 2.0 or newer." ) ; } if ( ! $ this -> getInspector ( ) -> isGitUserSet ( ) ) { if ( ! $ this -> getConfigVa...
Validates that Git user is configured .
5,381
public function commitMsgHook ( $ message ) { $ this -> say ( 'Validating commit message syntax...' ) ; $ pattern = $ this -> getConfigValue ( 'git.commit-msg.pattern' ) ; $ help_description = $ this -> getConfigValue ( 'git.commit-msg.help_description' ) ; $ example = $ this -> getConfigValue ( 'git.commit-msg.example...
Validates a git commit message .
5,382
public function preCommitHook ( $ changed_files ) { $ collection = $ this -> collectionBuilder ( ) ; $ collection -> setProgressIndicator ( NULL ) ; $ collection -> addCode ( function ( ) use ( $ changed_files ) { return $ this -> invokeCommands ( [ 'tests:phpcs:sniff:files' => [ 'file_list' => $ changed_files ] , 'tes...
Validates staged files .
5,383
public function validateDrushConfig ( CommandData $ commandData ) { $ alias = $ this -> getConfigValue ( 'drush.alias' ) ; if ( $ alias && ! $ this -> getInspector ( ) -> isDrushAliasValid ( "$alias" ) ) { $ this -> logger -> error ( "Invalid drush alias '@$alias'." ) ; $ this -> logger -> info ( 'Troubleshooting sugge...
Validates drush configuration for failed commands .
5,384
public static function munge ( $ file1 , $ file2 ) { $ file1_contents = file ( $ file1 ) ; $ file2_contents = file ( $ file2 ) ; $ munged_contents = self :: arrayMergeNoDuplicates ( $ file1_contents , $ file2_contents ) ; return ( string ) $ munged_contents ; }
Merges the arrays in two text files .
5,385
public static function arrayMergeNoDuplicates ( array & $ array1 , array & $ array2 ) { $ merged = array_merge ( $ array1 , $ array2 ) ; $ merged_without_dups = array_unique ( $ merged ) ; $ merged_rekeyed = array_values ( $ merged_without_dups ) ; return $ merged_rekeyed ; }
Merges two arrays and removes duplicate values .
5,386
public function all ( ) { $ commands = [ 'tests:composer:validate' , 'tests:php:lint' , 'tests:phpcs:sniff:all' , 'tests:yaml:lint:all' , 'tests:twig:lint:all' , ] ; if ( $ this -> getConfigValue ( 'validate.acsf' ) == TRUE ) { $ commands [ ] = 'tests:acsf:validate' ; } $ status_code = $ this -> invokeCommands ( $ comm...
Runs all code validation commands .
5,387
public function performAllChecks ( ) { $ this -> checkRequire ( ) ; $ this -> checkBltRequireDev ( ) ; if ( ! $ this -> getInspector ( ) -> isVmCli ( ) ) { $ this -> checkPrestissimo ( ) ; } $ this -> checkComposerConfig ( ) ; return $ this -> problems ; }
Checks that composer . json is configured correctly .
5,388
protected function checkComposerConfig ( ) { $ this -> compareComposerConfig ( 'autoload' , 'psr-4' ) ; $ this -> compareComposerConfig ( 'autoload-dev' , 'psr-4' ) ; $ this -> compareComposerConfig ( 'extra' , 'installer-paths' ) ; $ this -> compareComposerConfig ( 'extra' , 'enable-patching' ) ; $ this -> compareComp...
Emits a warning if project Composer config is different than default .
5,389
protected function checkUriResponse ( ) { $ site_available = $ this -> getExecutor ( ) -> execute ( "curl -I --insecure " . $ this -> drushStatus [ 'uri' ] ) -> run ( ) -> wasSuccessful ( ) ; if ( ! $ site_available ) { $ this -> logProblem ( __FUNCTION__ , [ "Did not get a response from {$this->drushStatus['uri']}" , ...
Checks that configured URI responds to requests .
5,390
protected function checkHttps ( ) { if ( strstr ( $ this -> drushStatus [ 'uri' ] , 'https' ) ) { if ( ! $ this -> getExecutor ( ) -> execute ( 'curl -cacert ' . $ this -> drushStatus [ 'uri' ] ) -> run ( ) -> wasSuccessful ( ) ) { $ this -> logProblem ( __FUNCTION__ , [ "The SSL certificate for your local site appears...
Checks that SSL cert is valid for configured URI .
5,391
public function wizard ( $ options = [ 'recipe' => InputOption :: VALUE_REQUIRED , ] ) { $ recipe_filename = $ options [ 'recipe' ] ; if ( $ recipe_filename ) { $ answers = $ this -> loadRecipeFile ( $ recipe_filename ) ; } else { $ answers = $ this -> askForAnswers ( ) ; } $ this -> say ( "<comment>You have entered th...
Wizard for setting initial configuration .
5,392
protected function loadRecipeFile ( $ filename ) { if ( ! file_exists ( $ filename ) ) { throw new FileNotFoundException ( $ filename ) ; } $ recipe = Yaml :: parse ( file_get_contents ( $ filename ) ) ; $ configs = [ $ recipe ] ; $ processor = new Processor ( ) ; $ configuration_tree = new ProjectConfiguration ( ) ; $...
Load a recipe .
5,393
protected function askForAnswers ( ) { $ this -> say ( "<info>Let's start by entering some information about your project.</info>" ) ; $ answers [ 'human_name' ] = $ this -> askDefault ( "Project name (human readable):" , $ this -> getConfigValue ( 'project.human_name' ) ) ; $ default_machine_name = StringManipulator :...
Prompts the user for information .
5,394
public function validate ( ) { $ this -> say ( "Validating composer.json and composer.lock..." ) ; $ result = $ this -> taskExecStack ( ) -> dir ( $ this -> getConfigValue ( 'repo.root' ) ) -> exec ( 'composer validate --no-check-all --ansi' ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { $ this -> say ( $ resu...
Validates root composer . json and composer . lock files .
5,395
protected function checkDeprecatedKeys ( ) { $ deprecated_keys = [ 'project.hash_salt' , 'project.profile.contrib' , 'project.vendor' , 'project.description' , 'project.themes' , 'hosting' , ] ; $ deprecated_keys_exist = FALSE ; $ outcome = [ ] ; foreach ( $ deprecated_keys as $ deprecated_key ) { if ( $ this -> getCon...
Checks that is configured correctly at a high level .
5,396
public function vm ( $ options = [ 'no-boot' => FALSE ] ) { if ( ! $ this -> getInspector ( ) -> isDrupalVmConfigPresent ( ) ) { $ confirm = $ this -> confirm ( "Drupal VM is not currently installed. Install it now? " , TRUE ) ; if ( $ confirm ) { $ this -> install ( ) ; } else { return FALSE ; } } if ( ! $ this -> get...
Configures and boots a Drupal VM .
5,397
public function nuke ( ) { $ confirm = $ this -> confirm ( "This will destroy your VM, and delete all associated configuration. Continue?" ) ; if ( $ confirm ) { $ this -> taskExecStack ( ) -> exec ( "vagrant destroy" ) -> dir ( $ this -> getConfigValue ( 'repo.root' ) ) -> printOutput ( TRUE ) -> stopOnFail ( ) -> run...
Destroys existing VM and all related configuration .
5,398
protected function config ( ) { $ this -> say ( "Generating default configuration for Drupal VM..." ) ; $ this -> createDrushAlias ( ) ; $ this -> createConfigFiles ( ) ; $ this -> customizeConfigFiles ( ) ; $ vm_config = Yaml :: parse ( file_get_contents ( $ this -> projectDrupalVmConfigFile ) ) ; $ this -> validateCo...
Generates default configuration for Drupal VM .
5,399
protected function localInitialize ( ) { if ( ! $ this -> getInspector ( ) -> isBltLocalConfigFilePresent ( ) ) { $ this -> invokeCommands ( [ 'blt:init:settings' ] ) ; } $ filename = $ this -> getConfigValue ( 'blt.config-files.local' ) ; $ this -> logger -> info ( "Updating $filename" ) ; $ contents = Yaml :: parse (...
Configures local machine to use Drupal VM as default env for BLT commands .