idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
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 site <comment>$multisite</comment>..." ) ; $ this -> switchSiteContext ( $ multisite ) ; $ result = $ this -> syncDb ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { $ this -> logger -> error ( "Could not sync database for site <comment>$multisite</comment>." ) ; throw new BltException ( "Could not sync database." ) ; } } return $ exit_code ; }
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 ( $ local_alias ) -> option ( '--target-dump' , sys_get_temp_dir ( ) . '/tmp.target.sql.gz' ) -> option ( 'structure-tables-key' , 'lightweight' ) -> option ( 'create-db' ) ; if ( $ this -> getConfigValue ( 'drush.sanitize' ) ) { $ task -> drush ( 'sql-sanitize' ) ; } $ task -> drush ( 'cr' ) ; $ task -> drush ( 'sqlq "TRUNCATE cache_entity"' ) ; $ result = $ task -> run ( ) ; return $ result ; }
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 ( $ _ENV [ 'environment' ] ) ) { $ environment = $ _ENV [ 'environment' ] ; } if ( isset ( $ environment ) ) { $ enable_key = "modules.$environment.enable" ; $ this -> doToggleModules ( 'pm-enable' , $ enable_key ) ; $ disable_key = "modules.$environment.uninstall" ; $ this -> doToggleModules ( 'pm-uninstall' , $ disable_key ) ; } else { $ this -> say ( "Environment is unset. Skipping drupal:toggle:modules..." ) ; } }
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 ) ; $ modules_list = implode ( ' ' , $ modules ) ; $ result = $ this -> taskDrush ( ) -> drush ( "$command $modules_list" ) -> run ( ) ; $ exit_code = $ result -> getExitCode ( ) ; } else { $ exit_code = 0 ; $ this -> logger -> info ( "$config_key is not set." ) ; } if ( $ exit_code ) { throw new BltException ( "Could not toggle modules listed in $config_key." ) ; } }
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 -> logger -> warning ( "You should execute all BLT commands from within Drupal VM." ) ; $ this -> logger -> warning ( "Use <comment>vagrant ssh</comment> to enter the VM." ) ; $ continue = $ this -> confirm ( "Do you want to continue and execute this command on the host machine?" ) ; if ( ! $ continue ) { throw new BltException ( "Command terminated by user." ) ; } } }
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_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Could not initialize Travis CI configuration." ) ; } $ this -> say ( "<info>A pre-configured .travis.yml file was copied to your repository root.</info>" ) ; }
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_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Could not initialize the GitLab Pipelines configuration." ) ; } $ this -> say ( "<info>A pre-configured .gitlab-ci.yml file was copied to your repository root.</info>" ) ; $ this -> logger -> warning ( "GitLab support is experimental and may not support all BLT features." ) ; }
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 :: mergeKeyed ( $ file1_contents , $ file2_contents ) ; if ( array_key_exists ( 'require' , $ output ) && is_array ( $ output [ 'require' ] ) ) { $ output [ 'require' ] = ( object ) $ output [ 'require' ] ; } if ( array_key_exists ( 'require-dev' , $ output ) && is_array ( $ output [ 'require-dev' ] ) ) { $ output [ 'require-dev' ] = ( object ) $ output [ 'require-dev' ] ; } $ output_json = json_encode ( $ output , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ; return $ output_json ; }
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_exists ( $ key , $ file2_contents ) ) { $ file2_contents [ $ key ] = [ ] ; } $ output [ $ key ] = ArrayManipulator :: arrayMergeRecursiveDistinct ( $ file1_contents [ $ key ] , $ file2_contents [ $ key ] ) ; } return $ output ; }
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 ( $ fileset_ids ) ; $ this -> executeTwigLintCommandAgainstFilesets ( $ filesets ) ; }
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 -> getFilesets ( $ fileset_ids , TRUE ) ; foreach ( $ filesets as $ fileset_id => $ fileset ) { $ filesets [ $ fileset_id ] = $ fileset_manager -> filterFilesByFileset ( $ files , $ fileset ) ; } $ this -> executeTwigLintCommandAgainstFilesets ( $ filesets ) ; }
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 => $ fileset ) { if ( ! is_null ( $ fileset ) && iterator_count ( $ fileset ) ) { $ this -> say ( "Iterating over fileset $fileset_id..." ) ; $ files = iterator_to_array ( $ fileset ) ; $ input = new ArrayInput ( [ 'filename' => $ files ] ) ; $ exit_code = $ application -> runCommand ( $ command , $ input , $ this -> output ( ) ) ; if ( $ exit_code ) { $ passed = FALSE ; $ failed_filesets [ ] = $ fileset_id ; } } else { $ this -> logger -> info ( "No files were found in fileset $fileset_id. Skipped." ) ; } } if ( ! $ passed ) { throw new BltException ( "Linting twig against fileset(s) " . implode ( ', ' , $ failed_filesets ) . " returned a non-zero exit code.`" ) ; } $ this -> say ( "All Twig files contain valid syntax." ) ; }
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 -> getConfigValue ( 'validate.twig.filters' ) ; $ drupal_filters = [ ] ; if ( $ matches_count = preg_match_all ( "#new \\\\Twig_SimpleFilter\('([^']+)',#" , $ extension_file_contents , $ matches ) ) { $ drupal_filters = $ matches [ 1 ] ; } $ twig_filters = array_merge ( $ twig_filters , $ drupal_filters ) ; foreach ( $ twig_filters as $ filter ) { $ twig -> addFilter ( new \ Twig_SimpleFilter ( $ filter , function ( $ node = '' , array $ args = [ ] ) { } , [ 'is_variadic' => TRUE , ] ) ) ; } $ twig_functions = ( array ) $ this -> getConfigValue ( 'validate.twig.functions' ) ; $ drupal_functions = [ ] ; if ( $ matches_count = preg_match_all ( "#new \\\\Twig_SimpleFunction\('([^']+)',#" , $ extension_file_contents , $ matches ) ) { $ drupal_functions = $ matches [ 1 ] ; } $ twig_functions = array_merge ( $ twig_functions , $ drupal_functions ) ; foreach ( $ twig_functions as $ function ) { $ twig -> addFunction ( new \ Twig_SimpleFunction ( $ function , function ( array $ args = [ ] ) { } , [ 'is_variadic' => TRUE , ] ) ) ; } $ token_parser_filename = $ repo_root . '/docroot/core/lib/Drupal/Core/Template/TwigTransTokenParser.php' ; if ( file_exists ( $ token_parser_filename ) ) { require_once $ token_parser_filename ; $ twig -> addTokenParser ( new TwigTransTokenParser ( ) ) ; } $ command = new TwigLintCommand ( ) ; $ command -> setTwigEnvironment ( $ twig ) ; return $ command ; }
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 -> getInspector ( ) -> isHashSaltPresent ( ) ) { $ this -> logger -> warning ( "<comment>salt.txt</comment> is missing." ) ; $ missing = TRUE ; } if ( $ missing ) { $ confirm = $ this -> confirm ( "Do you want to generate this required settings file(s)?" ) ; if ( $ confirm ) { $ bin = $ this -> getConfigValue ( 'composer.bin' ) ; $ this -> executor -> execute ( "$bin/blt blt:init:settings" ) -> printOutput ( TRUE ) -> run ( ) ; } } }
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 ( $ confirm ) { $ bin = $ this -> getConfigValue ( 'composer.bin' ) ; $ this -> executor -> execute ( "$bin/blt setup" ) -> interactive ( $ this -> input ( ) -> isInteractive ( ) ) -> run ( ) ; $ this -> getInspector ( ) -> clearState ( ) ; } } }
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' ; return $ installed ; }
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 ( ) -> wasSuccessful ( ) ; }
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 ; } $ major_version = substr ( $ version , 0 , 1 ) ; return ( int ) $ major_version ; }
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 ( "Drupal VM $statement initialized." ) ; } return $ this -> isDrupalVmLocallyInitialized ; }
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 name matches project.machine_name" ) ; $ valid = FALSE ; } else { if ( $ status [ $ machine_name ] [ 'state' ] == 'not_created' ) { $ this -> logger -> error ( "Drupal VM config has been initialized, but the VM has not been created. Please re-run `blt vm`." ) ; $ valid = FALSE ; } } $ file_path = $ this -> getConfigValue ( 'vm.config' ) ; if ( ! file_exists ( $ file_path ) ) { $ this -> logger -> error ( "$file_path is missing. Please re-run `blt vm`." ) ; $ valid = FALSE ; } return $ valid ; }
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 = ! empty ( $ status [ $ machine_name ] [ 'state' ] ) && $ status [ $ machine_name ] [ 'state' ] == 'running' ; $ statement = $ this -> isDrupalVmBooted ? "is" : "is not" ; $ this -> logger -> debug ( "Drupal VM $statement booted." ) ; } return $ 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 = $ home_dir . '/.zshrc' ; } elseif ( file_exists ( $ home_dir . '/.bash_profile' ) ) { $ file = $ home_dir . '/.bash_profile' ; } elseif ( file_exists ( $ home_dir . '/.bashrc' ) ) { $ file = $ home_dir . '/.bashrc' ; } elseif ( file_exists ( $ home_dir . '/.profile' ) ) { $ file = $ home_dir . '/.profile' ; } elseif ( file_exists ( $ home_dir . '/.functions' ) ) { $ file = $ home_dir . '/.functions' ; } return $ file ; }
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_local_config_file ) ) ; $ processor -> extend ( $ loader -> load ( $ this -> getConfigValue ( 'repo.root' ) . '/tests/behat/behat.yml' ) ) ; $ behat_local_config -> import ( $ processor -> export ( ) ) ; return $ behat_local_config ; }
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.extensions.Behat\MinkExtension.base_url in local.yml.' ) ; $ this -> logger -> warning ( 'project.local.uri = ' . $ this -> getConfigValue ( 'project.local.uri' ) ) ; $ this -> logger -> warning ( 'local.extensions.Behat\MinkExtension.base_url = ' . $ local_behat_config -> get ( 'local.extensions.Behat\MinkExtension.base_url' ) ) ; return FALSE ; } if ( $ this -> getConfigValue ( 'tests.run-server' ) ) { if ( $ this -> getConfigValue ( 'tests.server.url' ) != $ this -> getConfigValue ( 'project.local.uri' ) ) { $ this -> logger -> warning ( "tests.run-server is enabled, but the server URL does not match Drupal's base URL." ) ; $ this -> logger -> warning ( 'project.local.uri = ' . $ this -> getConfigValue ( 'project.local.uri' ) ) ; $ this -> logger -> warning ( 'tests.server.url = ' . $ this -> getConfigValue ( 'tests.server.url' ) ) ; $ this -> logger -> warning ( 'local.extensions.Behat\MinkExtension.base_url = ' . $ local_behat_config -> get ( 'local.extensions.Behat\MinkExtension.base_url' ) ) ; return FALSE ; } } if ( ! $ this -> areBehatConfigFilesPresent ( ) ) { return FALSE ; } return TRUE ; }
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' ) -> getLatestUpdateMethodVersion ( ) ; } return $ version ; }
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' ) !== FALSE ; return $ identical ; }
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 ( 'drush.dir' ) ) ; } if ( ! isset ( $ this -> uri ) ) { $ this -> uri = $ this -> getConfig ( ) -> get ( 'drush.uri' ) ; } if ( ! isset ( $ this -> alias ) ) { $ this -> alias ( $ this -> getConfig ( ) -> get ( 'drush.alias' ) ) ; } if ( ! isset ( $ this -> interactive ) ) { $ this -> interactive ( FALSE ) ; } if ( ! isset ( $ this -> ansi ) ) { $ this -> ansi ( $ this -> getConfig ( ) -> get ( 'drush.ansi' ) ) ; } $ this -> defaultsInitialized = TRUE ; }
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 -> arguments ) && ! empty ( $ this -> arguments ) ) { throw new TaskException ( $ this , "A drush command must be added to the stack before setting arguments: {$this->arguments}" ) ; } }
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 ( ) ; switch ( $ verbosity_threshold ) { case OutputInterface :: VERBOSITY_VERBOSE : $ this -> verbose ( TRUE ) ; break ; case OutputInterface :: VERBOSITY_VERY_VERBOSE : $ this -> veryVerbose ( TRUE ) ; break ; case OutputInterface :: VERBOSITY_DEBUG : $ this -> debug ( TRUE ) ; break ; } } if ( $ this -> verbosityThreshold ( ) >= OutputInterface :: VERBOSITY_VERBOSE && $ this -> verbose !== FALSE ) { $ this -> verbose ( TRUE ) ; } if ( ( $ this -> debug || $ this -> getConfig ( ) -> get ( 'drush.debug' ) ) && $ this -> getConfig ( ) -> get ( 'drush.debug' ) !== FALSE ) { $ this -> option ( '-vvv' ) ; } elseif ( ( $ this -> veryVerbose || $ this -> getConfig ( ) -> get ( 'drush.veryVerbose' ) ) && $ this -> getConfig ( ) -> get ( 'drush.veryVerbose' ) !== FALSE ) { $ this -> option ( '-vv' ) ; } elseif ( ( $ this -> verbose || $ this -> getConfig ( ) -> get ( 'drush.verbose' ) ) && $ this -> getConfig ( ) -> get ( 'drush.verbose' ) !== FALSE ) { $ this -> option ( '-v' ) ; } if ( $ this -> include ) { $ this -> option ( 'include' , $ this -> include ) ; } if ( $ this -> ansi ) { $ this -> option ( "ansi" ) ; } }
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 -> options [ $ commandNumber ] ) ? $ this -> options [ $ commandNumber ] : '' ; $ command = $ command . $ options . $ globalOptions ; $ this -> exec ( $ command ) -> dir ( $ this -> dir ) ; } }
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__ . ":$key" , "$title is not set." , 'error' ) ; continue ; } $ path = $ this -> drushStatus [ '%paths' ] [ $ key ] ; if ( substr ( $ path , 0 , 1 ) == '/' ) { $ full_path = $ path ; } else { $ full_path = $ this -> getConfigValue ( 'docroot' ) . "/$path" ; } if ( file_exists ( $ full_path ) ) { if ( ! is_writable ( $ full_path ) ) { $ this -> logProblem ( __FUNCTION__ . ":$key" , [ "$title is not writable." , "" , "Change the permissions on $full_path." , "Run `chmod 750 $full_path`." , ] , 'error' ) ; } } else { $ outcome = [ "$title does not exist." , "" , "Create $full_path." , ] ; if ( in_array ( $ key , [ '%files' , '%private' ] ) ) { $ outcome [ ] = "Installing Drupal will create this directory for you." ; $ outcome [ ] = "Run `blt drupal:install` to install Drupal, or run `blt setup` to run the entire setup process." ; $ outcome [ ] = "Otherwise, run `mkdir -p $full_path`." ; $ outcome [ ] = "" ; } $ this -> logProblem ( __FUNCTION__ . ":$key" , $ outcome , 'error' ) ; } } }
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 ) { case 0 : $ this -> say ( '<info>No fixable errors were found, and so nothing was fixed.</info>' ) ; return 0 ; case 1 : $ this -> say ( '<comment>Please note that exit code 1 does not indicate an error for PHPCBF.</comment>' ) ; $ this -> say ( '<info>All fixable errors were fixed correctly. There may still be errors that could not be fixed automatically.</info>' ) ; return 0 ; case 2 : $ this -> logger -> warning ( 'PHPCBF failed to fix some of the fixable errors it found.' ) ; return $ exit_code ; default : throw new BltException ( "PHPCBF failed." ) ; } }
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 ) ) ; $ writable = $ writable && is_writable ( $ this -> directory ) ; if ( ! $ writable ) { throw new BltException ( 'Could not save data to a file because the path {path} cannot be written to.' , [ 'path' => $ this -> directory ] ) ; } }
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 Environment Variable PATH</info>" ) ; return ; } if ( ! $ this -> getInspector ( ) -> isBltAliasInstalled ( ) ) { $ config_file = $ this -> getInspector ( ) -> getCliConfigFile ( ) ; if ( is_null ( $ config_file ) ) { $ this -> logger -> warning ( "Could not find your CLI configuration file." ) ; $ this -> logger -> warning ( "Looked in ~/.zsh, ~/.bash_profile, ~/.bashrc, ~/.profile, and ~/.functions." ) ; $ created = $ this -> createBashProfile ( ) ; $ config_file = $ this -> getInspector ( ) -> getCliConfigFile ( ) ; if ( ! $ created || is_null ( $ config_file ) ) { $ this -> logger -> warning ( "Please create one of the aforementioned files, or create the BLT alias manually." ) ; return ; } } $ this -> say ( "BLT can automatically create a Bash alias to make it easier to run BLT tasks." ) ; $ this -> say ( "This alias will be created in <comment>$config_file</comment>." ) ; $ confirm = $ this -> confirm ( "Install alias?" ) ; if ( $ confirm ) { $ this -> createNewAlias ( ) ; } } elseif ( ! $ this -> isBltAliasUpToDate ( ) ) { $ this -> logger -> warning ( "Your BLT alias is out of date." ) ; $ confirm = $ this -> confirm ( "Would you like to update it?" ) ; if ( $ confirm ) { $ this -> updateAlias ( ) ; } } else { $ this -> say ( "<info>The BLT alias is already installed and up to date.</info>" ) ; } }
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_profile, ~/.profile, and ~/.functions." ) ; } else { $ canonical_alias = file_get_contents ( $ this -> getConfigValue ( 'blt.root' ) . '/scripts/blt/alias' ) ; $ result = $ this -> taskWriteToFile ( $ config_file ) -> text ( $ canonical_alias ) -> append ( TRUE ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to install BLT alias." ) ; } $ this -> say ( "<info>Added alias for blt to $config_file.</info>" ) ; $ this -> say ( "You may now use the <comment>blt</comment> command from anywhere within a BLT-generated repository." ) ; $ this -> say ( "Restart your terminal session or run <comment>source $config_file</comment> to use the new command." ) ; } }
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 -> getClosingBracketPosition ( $ contents , $ begin_alias_pos + strlen ( $ needle ) ) ; $ canonical_alias = file_get_contents ( $ this -> getConfigValue ( 'blt.root' ) . '/scripts/blt/alias' ) ; if ( ! is_null ( $ end_alias_pos ) ) { $ alias_length = $ end_alias_pos - $ begin_alias_pos + 1 ; $ alias = substr ( $ contents , $ begin_alias_pos , $ alias_length ) ; } return [ 'config_file' => $ config_file , 'contents' => $ contents , 'start_pos' => $ begin_alias_pos , 'end_pos' => $ end_alias_pos , 'length' => $ alias_length , 'alias' => $ alias , 'canonical_alias' => $ canonical_alias , ] ; }
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 BltException ( "Could not update BLT alias in {$alias_info['config_file']}." ) ; } $ this -> say ( "<info>The <comment>blt</comment> alias was updated in {$alias_info['config_file']}" ) ; $ this -> say ( "Execute <comment>source {$alias_info['config_file']}</comment> to update your terminal session." ) ; $ this -> say ( "You may then execute <comment>blt</comment> commands." ) ; }
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 ( $ brackets ) ; } if ( count ( $ brackets ) == 0 ) { return $ pos ; } } return NULL ; }
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 ( ) -> isInteractive ( ) ) { $ this -> fixViolationsInteractively ( ) ; throw new BltException ( "Initial execution of PHPCS failed. Re-run now that PHPCBF has fixed some violations." ) ; } else { $ this -> logger -> notice ( 'Try running `blt source:fix:php-standards` to automatically fix standards violations.' ) ; throw new BltException ( "PHPCS failed." ) ; } } }
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 -> taskWriteToFile ( $ temp_path ) -> lines ( $ files ) -> run ( ) ; $ arguments = "--file-list='$temp_path' -l" ; $ exit_code = $ this -> doSniff ( $ arguments ) ; unlink ( $ temp_path ) ; return $ exit_code ; } return 0 ; }
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 -> notice ( " * Executing the `acsf-init` command, provided by the drupal/acsf module." ) ; $ this -> logger -> notice ( " * Adding default factory-hooks to your application." ) ; $ this -> logger -> notice ( " * Adding `acsf` to `modules.local.uninstall` in your blt.yml" ) ; $ this -> logger -> notice ( "" ) ; $ this -> logger -> notice ( "Note that the default version of PHP on ACSF is generally not the same as Acquia Cloud." ) ; $ this -> logger -> notice ( "You may wish to adjust the PHP version of your local environment and CI tools to match." ) ; $ this -> logger -> notice ( "" ) ; $ this -> logger -> notice ( "For more information, see:" ) ; $ this -> logger -> notice ( "<comment>http://blt.readthedocs.io/en/latest/readme/acsf-setup</comment>" ) ; }
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' ] , ] ; $ this -> invokeCommand ( 'internal:composer:require' , $ package_options ) ; $ this -> say ( "In the future, you may pass in a custom value for acsf-version to override the default version, e.g., blt recipes:acsf:init:all --acsf-version='8.1.x-dev'" ) ; $ this -> acsfDrushInitialize ( ) ; $ this -> say ( 'Adding acsf-tools drush module as a dependency...' ) ; $ package_options = [ 'package_name' => 'acquia/acsf-tools' , 'package_version' => 'dev-9.x-dev' , ] ; $ this -> invokeCommand ( 'internal:composer:require' , $ package_options ) ; $ this -> say ( '<comment>ACSF Tools has been added. Some post-install configuration is necessary.</comment>' ) ; $ this -> say ( '<comment>See /drush/Commands/acsf_tools/README.md. </comment>' ) ; $ this -> say ( '<info>ACSF was successfully initialized.</info>' ) ; $ this -> say ( 'Adding nedsbeds/profile_split_enable module as a dependency...' ) ; $ package_options = [ 'package_name' => 'nedsbeds/profile_split_enable' , 'package_version' => '^1.0' , ] ; $ this -> invokeCommand ( 'internal:composer:require' , $ package_options ) ; $ this -> say ( '<comment>nedsbeds/profile_split_enable module has been added.</comment>' ) ; $ this -> say ( '<comment>Enable the module and setup profile splits to utilize.</comment>' ) ; $ project_yml = $ this -> getConfigValue ( 'blt.config-files.project' ) ; $ project_config = YamlMunge :: parseFile ( $ project_yml ) ; if ( ! empty ( $ project_config [ 'modules' ] ) ) { $ project_config [ 'modules' ] [ 'local' ] [ 'uninstall' ] [ ] = 'acsf' ; } YamlMunge :: writeFile ( $ project_yml , $ project_config ) ; }
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/drush acsf-init --include=\"$acsf_include\" --root=\"{$this->getConfigValue('docroot')}\" -y" ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to copy ACSF scripts." ) ; } return $ result ; }
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_FOLLOWLOCATION , TRUE ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , TRUE ) ; curl_setopt ( $ ch , CURLOPT_FILE , $ file ) ; curl_exec ( $ ch ) ; curl_close ( $ ch ) ; fclose ( $ file ) ; $ this -> _chmod ( $ destination , 0755 ) ; }
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 -> input ( ) -> isInteractive ( ) ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; return $ result ; }
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 ) { $ keys [ ] = $ iterator -> getSubIterator ( $ depth ) -> key ( ) ; } $ result [ implode ( $ glue , $ keys ) ] = $ leafValue ; } return $ result ; }
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_value === TRUE ) { $ sub_value = 'true' ; } elseif ( $ sub_value === FALSE ) { $ sub_value = 'false' ; } $ rows [ ] = [ "$key.$sub_key" , wordwrap ( $ sub_value , $ max_line_length , "\n" , TRUE ) , ] ; } } else { if ( $ value === TRUE ) { $ contents = 'true' ; } elseif ( $ value === FALSE ) { $ contents = 'false' ; } else { $ contents = wordwrap ( $ value , $ max_line_length , "\n" , TRUE ) ; } $ rows [ ] = [ $ key , $ contents ] ; } } return $ rows ; }
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 :: arrayMergeRecursiveExceptEmpty ( $ merged [ $ key ] , $ value ) ; } else { $ merged [ $ key ] = $ value ; } } return $ merged ; }
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 verify ACSF settings. Re-run acsf-init and commit the results." ) ; } }
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..." ) ; $ hook_source = $ this -> getConfigValue ( 'git.hooks.' . $ hook ) . "/$hook" ; $ path_to_hook_source = rtrim ( $ fs -> makePathRelative ( $ hook_source , $ project_hook_directory ) , '/' ) ; $ result = $ this -> taskFilesystemStack ( ) -> mkdir ( $ this -> getConfigValue ( 'repo.root' ) . '/.git/hooks' ) -> remove ( $ project_hook ) -> symlink ( $ path_to_hook_source , $ project_hook ) -> stopOnFail ( ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to install $hook git hook." ) ; } } else { if ( file_exists ( $ project_hook ) ) { $ this -> say ( "Removing disabled $hook git hook..." ) ; $ result = $ this -> taskFilesystemStack ( ) -> remove ( $ project_hook ) -> stopOnFail ( ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to remove disabled $hook git hook" ) ; } } else { $ this -> say ( "Skipping installation of $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-import' ) ; if ( in_array ( $ strategy , [ 'core-only' , 'config-split' ] ) ) { $ core_config_file = $ this -> getConfigValue ( 'docroot' ) . '/' . $ this -> getConfigValue ( "cm.core.dirs.$cm_core_key.path" ) . '/core.extension.yml' ; if ( ! file_exists ( $ core_config_file ) ) { $ this -> logger -> warning ( "BLT will NOT import configuration, $core_config_file was not found." ) ; return 0 ; } } $ exported_site_uuid = $ this -> getExportedSiteUuid ( $ cm_core_key ) ; if ( $ exported_site_uuid ) { $ task -> drush ( "config:set system.site uuid $exported_site_uuid" ) ; } switch ( $ strategy ) { case 'core-only' : $ this -> importCoreOnly ( $ task , $ cm_core_key ) ; break ; case 'config-split' : $ this -> importConfigSplit ( $ task , $ cm_core_key ) ; break ; case 'features' : $ this -> importFeatures ( $ task , $ cm_core_key ) ; if ( $ this -> getConfigValue ( 'cm.features.no-overrides' ) ) { $ this -> checkFeaturesOverrides ( ) ; } break ; } $ task -> drush ( "cache-rebuild" ) ; $ result = $ task -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Failed to import configuration!" ) ; } $ this -> checkConfigOverrides ( $ cm_core_key ) ; $ result = $ this -> invokeHook ( 'post-config-import' ) ; return $ result ; } }
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' ) ) { foreach ( $ this -> getConfigValue ( 'cm.features.bundle' ) as $ bundle ) { $ task -> drush ( "features-import-all" ) -> option ( 'bundle' , $ bundle ) ; $ task -> drush ( "features-import-all" ) -> option ( 'bundle' , $ bundle ) ; } } }
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 -> getConfigValue ( 'cm.features.bundle' ) as $ bundle ) { $ task -> drush ( "fl" ) -> option ( 'bundle' , $ bundle ) -> option ( 'format' , 'json' ) ; $ result = $ task -> printOutput ( TRUE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to determine if features in bundle $bundle are overridden." ) ; } $ output = $ result -> getMessage ( ) ; $ features_overridden = preg_match ( '/(changed|conflicts|added)( *)$/' , $ output ) ; if ( $ features_overridden ) { throw new BltException ( "A feature in the $bundle bundle is overridden. You must re-export this feature to incorporate the changes." ) ; } } } } }
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 ) ; $ site_uuid = $ site_config [ 'uuid' ] ; return $ site_uuid ; } return NULL ; }
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' => 'path' , 'url' => $ options [ 'blt-path' ] , ] ; $ composer_json -> require -> { 'acquia/blt' } = '*' ; file_put_contents ( $ composer_json_filepath , json_encode ( $ composer_json , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ) ; $ this -> taskExec ( 'composer update acquia/blt --with-dependencies' ) -> dir ( $ this -> getConfigValue ( 'repo.root' ) ) -> run ( ) ; }
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 ( "BLT settings are not included in settings file." ) ; } }
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 -> getConfigValue ( 'git.user.name' ) || ! $ this -> getConfigValue ( 'git.user.email' ) ) { $ this -> logger -> warning ( "Git user name or email is not configured. BLT will attempt to set a dummy user and email address for this commit." ) ; $ this -> config -> set ( 'git.user.name' , 'BLT dummy user' ) ; $ this -> config -> set ( 'git.user.email' , 'no-reply@example.com' ) ; } } }
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' ) ; $ this -> logger -> debug ( "Validing commit message with regex <comment>$pattern</comment>." ) ; if ( ! preg_match ( $ pattern , $ message ) ) { $ this -> logger -> error ( "Invalid commit message!" ) ; $ this -> say ( "Commit messages must conform to the regex $pattern" ) ; if ( ! empty ( $ help_description ) ) { $ this -> say ( "$help_description" ) ; } if ( ! empty ( $ example ) ) { $ this -> say ( "Example: $example" ) ; } $ this -> logger -> notice ( "To disable or customize Git hooks, see http://blt.rtfd.io/en/latest/readme/extending-blt/#git-hooks" ) ; return 1 ; } return 0 ; }
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 ] , 'tests:twig:lint:files' => [ 'file_list' => $ changed_files ] , 'tests:yaml:lint:files' => [ 'file_list' => $ changed_files ] , ] ) ; } ) ; $ changed_files_list = explode ( "\n" , $ changed_files ) ; if ( in_array ( 'composer.json' , $ changed_files_list ) || in_array ( 'composer.lock' , $ changed_files_list ) ) { $ collection -> addCode ( function ( ) use ( $ changed_files ) { return $ this -> invokeCommand ( 'tests:composer:validate' ) ; } ) ; } $ result = $ collection -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( $ result -> wasSuccessful ( ) ) { $ this -> say ( "<info>Your local code has passed git pre-commit validation.</info>" ) ; } return $ result ; }
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 suggestions:' ) ; $ this -> logger -> info ( 'Execute `drush site:alias` from within the docroot to see a list of available aliases.' ) ; $ this -> logger -> info ( "Execute `drush site:alias $alias` for information on the @$alias alias." ) ; $ this -> logger -> info ( "Execute `drush @$alias status` to determine the status of the application belonging to the alias." ) ; throw new BltException ( "Invalid drush alias '@$alias'." ) ; } }
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 ( $ commands ) ; return $ status_code ; }
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 -> compareComposerConfig ( 'extra' , 'composer-exit-on-patch-failure' ) ; $ this -> compareComposerConfig ( 'extra' , 'patchLevel' ) ; $ this -> compareComposerConfig ( 'repositories' , 'drupal' ) ; $ this -> compareComposerConfig ( 'scripts' , 'nuke' ) ; $ this -> compareComposerConfig ( 'scripts' , 'drupal-scaffold' ) ; }
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']}" , "Is your *AMP stack running?" , "Is your /etc/hosts file correctly configured?" , "Is your web server configured to serve this URI from {$this->drushStatus['root']}?" , "Is options.uri set correctly in {$this->localSiteDrushYml}?" , ] , 'error' ) ; } }
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 to be invalid for {$this->drushStatus['uri']}." , ] , 'error' ) ; } } }
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 the following values:</comment>" ) ; $ this -> printArrayAsTable ( $ answers ) ; $ continue = $ this -> confirm ( "Continue?" , TRUE ) ; if ( ! $ continue ) { return 1 ; } $ this -> updateProjectYml ( $ answers ) ; if ( ! empty ( $ answers [ 'ci' ] [ 'provider' ] ) ) { $ this -> invokeCommand ( "ci:{$answers['ci']['provider']}:init" ) ; } if ( $ answers [ 'vm' ] ) { $ this -> invokeCommand ( 'vm' , [ [ 'no-boot' => '--no-interaction' , ] , ] ) ; } }
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 ( ) ; $ processed_configuration = $ processor -> processConfiguration ( $ configuration_tree , $ configs ) ; return $ processed_configuration ; }
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 :: convertStringToMachineSafe ( $ answers [ 'human_name' ] ) ; $ answers [ 'machine_name' ] = $ this -> askDefault ( "Project machine name:" , $ default_machine_name ) ; $ default_prefix = StringManipulator :: convertStringToPrefix ( $ answers [ 'human_name' ] ) ; $ answers [ 'prefix' ] = $ this -> askDefault ( "Project prefix:" , $ default_prefix ) ; $ this -> say ( "<info>Great. Now let's make some choices about how your project will be set up.</info>" ) ; $ answers [ 'vm' ] = $ this -> confirm ( 'Do you want to create a VM?' ) ; $ ci = $ this -> confirm ( 'Do you want to use Continuous Integration?' ) ; if ( $ ci ) { $ provider_options = [ 'pipelines' => 'Acquia Pipelines' , 'travis' => 'Travis CI' , ] ; $ answers [ 'ci' ] [ 'provider' ] = $ this -> askChoice ( 'Choose a Continuous Integration provider:' , $ provider_options , 'travis' ) ; } $ cm = $ this -> confirm ( 'Do you want use Drupal core configuration management?' ) ; if ( $ cm ) { $ strategy_options = [ 'config-split' => 'Config Split (recommended)' , 'features' => 'Features' , 'core-only' => 'Core only' , ] ; $ answers [ 'cm' ] [ 'strategy' ] = $ this -> askChoice ( 'Choose a configuration management strategy:' , $ strategy_options , 'config-split' ) ; } else { $ answers [ 'cm' ] [ 'strategy' ] = 'none' ; } $ profile_options = [ 'lightning' => 'Lightning' , 'minimal' => 'Minimal' , 'standard' => 'Standard' , ] ; $ this -> say ( "You may change the installation profile later." ) ; $ answers [ 'profile' ] = $ this -> askChoice ( 'Choose an installation profile:' , $ profile_options , 'lightning' ) ; return $ answers ; }
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 ( $ result -> getMessage ( ) ) ; $ this -> logger -> error ( "composer.lock is invalid." ) ; $ this -> say ( "If this is simply a matter of the lock file being out of date, you may attempt to use `composer update --lock` to quickly generate a new hash in your lock file." ) ; $ this -> say ( "Otherwise, `composer update` is likely necessary." ) ; throw new BltException ( "composer.lock is invalid!" ) ; } }
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 -> getConfigValue ( $ deprecated_key ) ) { $ outcome [ ] = "The '$deprecated_key' key is deprecated. Please remove it from blt.yml." ; $ deprecated_keys_exist = TRUE ; } } if ( $ deprecated_keys_exist ) { $ this -> logProblem ( __FUNCTION__ . ':keys' , $ outcome , 'comment' ) ; } }
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 -> getInspector ( ) -> isDrupalVmLocallyInitialized ( ) ) { $ this -> localInitialize ( ) ; } else { $ this -> say ( "Drupal VM is already configured. In the future, please use vagrant commands to interact directly with the VM." ) ; } if ( ! $ options [ 'no-boot' ] && ! $ this -> getInspector ( ) -> isDrupalVmBooted ( ) ) { return $ this -> boot ( ) ; } }
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 ( ) ; $ this -> taskFilesystemStack ( ) -> remove ( $ this -> projectDrupalVmConfigFile ) -> remove ( $ this -> projectDrupalVmVagrantfile ) -> remove ( $ this -> getConfigValue ( 'blt.config-files.local' ) ) -> run ( ) ; $ this -> say ( "Your Drupal VM instance has been obliterated." ) ; $ this -> say ( "Please run `blt vm` to create a new one." ) ; } }
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 -> validateConfig ( $ vm_config ) ; $ this -> say ( "" ) ; $ this -> say ( "<info>BLT has created default configuration for your Drupal VM!</info>" ) ; $ this -> say ( " * The configuration file is <comment>{$this->projectDrupalVmConfigFile}</comment>." ) ; $ this -> say ( " * Be sure to commit this file as well as <comment>Vagrantfile</comment>." ) ; $ this -> say ( " * To customize the VM, follow the Quick Start Guide in Drupal VM's README:" ) ; $ this -> say ( " <comment>https://github.com/geerlingguy/drupal-vm#quick-start-guide</comment>" ) ; $ this -> say ( " * To run blt or drush commands against your VM, must SSH into the VM via <comment>vagrant ssh</comment>." ) ; $ this -> say ( " * From now on, please use vagrant commands to manage your virtual machine on this computer." ) ; $ this -> say ( "" ) ; }
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 ( file_get_contents ( $ filename ) ) ; $ contents [ 'vm' ] [ 'enable' ] = TRUE ; $ yaml = Yaml :: dump ( $ contents , 3 , 2 ) ; file_put_contents ( $ filename , $ yaml ) ; $ this -> say ( "<comment>$filename</comment> was modified." ) ; }
Configures local machine to use Drupal VM as default env for BLT commands .