repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
acquia/blt
src/Robo/Commands/Sync/SyncCommand.php
SyncCommand.syncDbAllSites
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; }
php
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; }
[ "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. @command drupal:sync:db:all-sites @aliases dsba sync:all:db @executeInVm
[ "Iteratively", "copies", "remote", "db", "to", "local", "db", "for", "each", "multisite", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Sync/SyncCommand.php#L92-L113
train
acquia/blt
src/Robo/Commands/Sync/SyncCommand.php
SyncCommand.syncDb
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; }
php
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; }
[ "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. @command drupal:sync:default:db @aliases dsb drupal:sync:db sync:db @validateDrushConfig @executeInVm
[ "Copies", "remote", "db", "to", "local", "db", "for", "default", "site", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Sync/SyncCommand.php#L124-L148
train
acquia/blt
src/Robo/Commands/Setup/ToggleModulesCommand.php
ToggleModulesCommand.toggleModules
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 modules. $enable_key = "modules.$environment.enable"; $this->doToggleModules('pm-enable', $enable_key); // Uninstall modules. $disable_key = "modules.$environment.uninstall"; $this->doToggleModules('pm-uninstall', $disable_key); } else { $this->say("Environment is unset. Skipping drupal:toggle:modules..."); } }
php
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 modules. $enable_key = "modules.$environment.enable"; $this->doToggleModules('pm-enable', $enable_key); // Uninstall modules. $disable_key = "modules.$environment.uninstall"; $this->doToggleModules('pm-uninstall', $disable_key); } else { $this->say("Environment is unset. Skipping drupal:toggle:modules..."); } }
[ "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 modules.", "$", "enable_key", "=", "\"modules.$environment.enable\"", ";", "$", "this", "->", "doToggleModules", "(", "'pm-enable'", ",", "$", "enable_key", ")", ";", "// Uninstall modules.", "$", "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. You may define the environment for which modules should be toggled by passing the --environment=[value] option to this command setting $_ENV['environment'] via the CLI, or defining environment in one of your BLT configuration files. @command drupal:toggle:modules @aliases dtm toggle setup:toggle-modules @validateDrushConfig @executeInVm
[ "Enables", "and", "uninstalls", "specified", "modules", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/ToggleModulesCommand.php#L28-L51
train
acquia/blt
src/Robo/Commands/Setup/ToggleModulesCommand.php
ToggleModulesCommand.doToggleModules
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."); } }
php
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."); } }
[ "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. @param string $command The drush command to execute, e.g., pm-enable or pm-uninstall. @param string $config_key The config key containing the array of modules. @throws \Acquia\Blt\Robo\Exceptions\BltException
[ "Enables", "or", "uninstalls", "an", "array", "of", "modules", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/ToggleModulesCommand.php#L63-L81
train
acquia/blt
src/Robo/Hooks/DrupalVmHook.php
DrupalVmHook.interactExecuteOnHost
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."); } } }
php
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."); } } }
[ "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. @hook interact @executeInVm @throws BltException
[ "Ask", "whether", "user", "would", "like", "to", "execute", "on", "host", "machine", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Hooks/DrupalVmHook.php#L19-L29
train
acquia/blt
src/Robo/Commands/Ci/CiCommand.php
CiCommand.travisInit
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>"); }
php
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>"); }
[ "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. @command recipes:ci:travis:init @aliases rcti ci:travis:init
[ "Initializes", "default", "Travis", "CI", "configuration", "for", "this", "project", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Ci/CiCommand.php#L42-L54
train
acquia/blt
src/Robo/Commands/Ci/CiCommand.php
CiCommand.gitlabInit
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."); }
php
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."); }
[ "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. @command recipes:ci:gitlab:init @aliases rcgi ci:gitlab:init
[ "Initializes", "default", "GitLab", "Pipelines", "configuration", "for", "this", "project", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Ci/CiCommand.php#L84-L95
train
acquia/blt
src/Robo/Common/ComposerMunge.php
ComposerMunge.mungeFiles
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); // Ensure that require and require-dev are objects and not arrays. 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; }
php
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); // Ensure that require and require-dev are objects and not arrays. 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; }
[ "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", ")", ";", "// Ensure that require and require-dev are objects and not arrays.", "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. @param string $file1 The file path to the first composer.json file. @param string $file2 The file path to the second composer.json file. @return string The new, merged composer.json contents.
[ "Selectively", "merges", "parts", "of", "two", "composer", ".", "json", "files", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Common/ComposerMunge.php#L21-L39
train
acquia/blt
src/Robo/Common/ComposerMunge.php
ComposerMunge.mergeKeyed
protected static function mergeKeyed($file1_contents, $file2_contents, $exclude_keys = []) { // Merge keyed arrays objects. $merge_keys = [ 'config', 'extra', ]; $output = $file1_contents; foreach ($merge_keys as $key) { // Set empty keys to empty placeholder arrays. if (!array_key_exists($key, $file1_contents)) { $file1_contents[$key] = []; } if (!array_key_exists($key, $file2_contents)) { $file2_contents[$key] = []; } // Merge! $output[$key] = ArrayManipulator::arrayMergeRecursiveDistinct($file1_contents[$key], $file2_contents[$key]); } return $output; }
php
protected static function mergeKeyed($file1_contents, $file2_contents, $exclude_keys = []) { // Merge keyed arrays objects. $merge_keys = [ 'config', 'extra', ]; $output = $file1_contents; foreach ($merge_keys as $key) { // Set empty keys to empty placeholder arrays. if (!array_key_exists($key, $file1_contents)) { $file1_contents[$key] = []; } if (!array_key_exists($key, $file2_contents)) { $file2_contents[$key] = []; } // Merge! $output[$key] = ArrayManipulator::arrayMergeRecursiveDistinct($file1_contents[$key], $file2_contents[$key]); } return $output; }
[ "protected", "static", "function", "mergeKeyed", "(", "$", "file1_contents", ",", "$", "file2_contents", ",", "$", "exclude_keys", "=", "[", "]", ")", "{", "// Merge keyed arrays objects.", "$", "merge_keys", "=", "[", "'config'", ",", "'extra'", ",", "]", ";", "$", "output", "=", "$", "file1_contents", ";", "foreach", "(", "$", "merge_keys", "as", "$", "key", ")", "{", "// Set empty keys to empty placeholder arrays.", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "file1_contents", ")", ")", "{", "$", "file1_contents", "[", "$", "key", "]", "=", "[", "]", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "file2_contents", ")", ")", "{", "$", "file2_contents", "[", "$", "key", "]", "=", "[", "]", ";", "}", "// Merge!", "$", "output", "[", "$", "key", "]", "=", "ArrayManipulator", "::", "arrayMergeRecursiveDistinct", "(", "$", "file1_contents", "[", "$", "key", "]", ",", "$", "file2_contents", "[", "$", "key", "]", ")", ";", "}", "return", "$", "output", ";", "}" ]
Merges specific keyed arrays and objects in composer.json files. @param $file1_contents @param $file2_contents @param array $exclude_keys @return mixed
[ "Merges", "specific", "keyed", "arrays", "and", "objects", "in", "composer", ".", "json", "files", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Common/ComposerMunge.php#L50-L71
train
acquia/blt
src/Robo/Commands/Validate/TwigCommand.php
TwigCommand.lintFileSets
public function lintFileSets() { $this->say("Validating twig syntax for all custom modules and themes..."); /** @var \Acquia\Blt\Robo\Filesets\FilesetManager $fileset_manager */ $fileset_manager = $this->getContainer()->get('filesetManager'); $fileset_ids = $this->getConfigValue('validate.twig.filesets'); $filesets = $fileset_manager->getFilesets($fileset_ids); $this->executeTwigLintCommandAgainstFilesets($filesets); }
php
public function lintFileSets() { $this->say("Validating twig syntax for all custom modules and themes..."); /** @var \Acquia\Blt\Robo\Filesets\FilesetManager $fileset_manager */ $fileset_manager = $this->getContainer()->get('filesetManager'); $fileset_ids = $this->getConfigValue('validate.twig.filesets'); $filesets = $fileset_manager->getFilesets($fileset_ids); $this->executeTwigLintCommandAgainstFilesets($filesets); }
[ "public", "function", "lintFileSets", "(", ")", "{", "$", "this", "->", "say", "(", "\"Validating twig syntax for all custom modules and themes...\"", ")", ";", "/** @var \\Acquia\\Blt\\Robo\\Filesets\\FilesetManager $fileset_manager */", "$", "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. @command tests:twig:lint:all @aliases ttla twig tests:twig:lint validate:twig
[ "Executes", "Twig", "validator", "against", "all", "validate", ".", "twig", ".", "filesets", "files", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Validate/TwigCommand.php#L25-L33
train
acquia/blt
src/Robo/Commands/Validate/TwigCommand.php
TwigCommand.lintFileList
public function lintFileList($file_list) { $this->say("Linting twig files..."); $files = explode("\n", $file_list); /** @var \Acquia\Blt\Robo\Filesets\FilesetManager $fileset_manager */ $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); }
php
public function lintFileList($file_list) { $this->say("Linting twig files..."); $files = explode("\n", $file_list); /** @var \Acquia\Blt\Robo\Filesets\FilesetManager $fileset_manager */ $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); }
[ "public", "function", "lintFileList", "(", "$", "file_list", ")", "{", "$", "this", "->", "say", "(", "\"Linting twig files...\"", ")", ";", "$", "files", "=", "explode", "(", "\"\\n\"", ",", "$", "file_list", ")", ";", "/** @var \\Acquia\\Blt\\Robo\\Filesets\\FilesetManager $fileset_manager */", "$", "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. @command tests:twig:lint:files @aliases ttlf @param string $file_list A list of files to scan, separated by \n.
[ "Executes", "Twig", "validator", "against", "a", "list", "of", "files", "if", "in", "twig", ".", "filesets", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Validate/TwigCommand.php#L44-L57
train
acquia/blt
src/Robo/Commands/Validate/TwigCommand.php
TwigCommand.executeTwigLintCommandAgainstFilesets
protected function executeTwigLintCommandAgainstFilesets(array $filesets) { $command = $this->createTwigLintCommand(); /** @var \Acquia\Blt\Robo\Application $application */ $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) { // We iterate over all filesets before throwing an exception. $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.`"); } // If exception wasn't thrown, checks were successful. $this->say("All Twig files contain valid syntax."); }
php
protected function executeTwigLintCommandAgainstFilesets(array $filesets) { $command = $this->createTwigLintCommand(); /** @var \Acquia\Blt\Robo\Application $application */ $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) { // We iterate over all filesets before throwing an exception. $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.`"); } // If exception wasn't thrown, checks were successful. $this->say("All Twig files contain valid syntax."); }
[ "protected", "function", "executeTwigLintCommandAgainstFilesets", "(", "array", "$", "filesets", ")", "{", "$", "command", "=", "$", "this", "->", "createTwigLintCommand", "(", ")", ";", "/** @var \\Acquia\\Blt\\Robo\\Application $application */", "$", "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", ")", "{", "// We iterate over all filesets before throwing an exception.", "$", "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.`\"", ")", ";", "}", "// If exception wasn't thrown, checks were successful.", "$", "this", "->", "say", "(", "\"All Twig files contain valid syntax.\"", ")", ";", "}" ]
Lints twig against multiple filesets. @param \Symfony\Component\Finder\Finder[] $filesets @throws \Acquia\Blt\Robo\Exceptions\BltException
[ "Lints", "twig", "against", "multiple", "filesets", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Validate/TwigCommand.php#L66-L98
train
acquia/blt
src/Robo/Commands/Validate/TwigCommand.php
TwigCommand.createTwigLintCommand
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'); // Get any custom defined Twig filters to be ignored by linter. $twig_filters = (array) $this->getConfigValue('validate.twig.filters'); // Add Twig filters from Drupal TwigExtension to be ignored. $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) { // Add two default arguments and set to variadic so that filters with // named arguments will be whitelisted. // @see \TwigNode_Expression_Call::getArguments // @see \TwigNode_Expression_Call::call() $twig->addFilter(new \Twig_SimpleFilter($filter, function ($node = '', array $args = []) {}, [ 'is_variadic' => TRUE, ])); } // Get any custom defined Twig functions to be ignored by linter. $twig_functions = (array) $this->getConfigValue('validate.twig.functions'); // Add Twig functions from Drupal TwigExtension to be ignored. $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) { // Add default argument and set to variadic so that functions with named // arguments will be whitelisted. // @see \TwigNode_Expression_Call::getArguments // @see \TwigNode_Expression_Call::call() $twig->addFunction(new \Twig_SimpleFunction($function, function (array $args = []) {}, [ 'is_variadic' => TRUE, ])); } // Add Drupal Twig parser to include trans tag. $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; }
php
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'); // Get any custom defined Twig filters to be ignored by linter. $twig_filters = (array) $this->getConfigValue('validate.twig.filters'); // Add Twig filters from Drupal TwigExtension to be ignored. $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) { // Add two default arguments and set to variadic so that filters with // named arguments will be whitelisted. // @see \TwigNode_Expression_Call::getArguments // @see \TwigNode_Expression_Call::call() $twig->addFilter(new \Twig_SimpleFilter($filter, function ($node = '', array $args = []) {}, [ 'is_variadic' => TRUE, ])); } // Get any custom defined Twig functions to be ignored by linter. $twig_functions = (array) $this->getConfigValue('validate.twig.functions'); // Add Twig functions from Drupal TwigExtension to be ignored. $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) { // Add default argument and set to variadic so that functions with named // arguments will be whitelisted. // @see \TwigNode_Expression_Call::getArguments // @see \TwigNode_Expression_Call::call() $twig->addFunction(new \Twig_SimpleFunction($function, function (array $args = []) {}, [ 'is_variadic' => TRUE, ])); } // Add Drupal Twig parser to include trans tag. $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; }
[ "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'", ")", ";", "// Get any custom defined Twig filters to be ignored by linter.", "$", "twig_filters", "=", "(", "array", ")", "$", "this", "->", "getConfigValue", "(", "'validate.twig.filters'", ")", ";", "// Add Twig filters from Drupal TwigExtension to be ignored.", "$", "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", ")", "{", "// Add two default arguments and set to variadic so that filters with", "// named arguments will be whitelisted.", "// @see \\TwigNode_Expression_Call::getArguments", "// @see \\TwigNode_Expression_Call::call()", "$", "twig", "->", "addFilter", "(", "new", "\\", "Twig_SimpleFilter", "(", "$", "filter", ",", "function", "(", "$", "node", "=", "''", ",", "array", "$", "args", "=", "[", "]", ")", "{", "}", ",", "[", "'is_variadic'", "=>", "TRUE", ",", "]", ")", ")", ";", "}", "// Get any custom defined Twig functions to be ignored by linter.", "$", "twig_functions", "=", "(", "array", ")", "$", "this", "->", "getConfigValue", "(", "'validate.twig.functions'", ")", ";", "// Add Twig functions from Drupal TwigExtension to be ignored.", "$", "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", ")", "{", "// Add default argument and set to variadic so that functions with named", "// arguments will be whitelisted.", "// @see \\TwigNode_Expression_Call::getArguments", "// @see \\TwigNode_Expression_Call::call()", "$", "twig", "->", "addFunction", "(", "new", "\\", "Twig_SimpleFunction", "(", "$", "function", ",", "function", "(", "array", "$", "args", "=", "[", "]", ")", "{", "}", ",", "[", "'is_variadic'", "=>", "TRUE", ",", "]", ")", ")", ";", "}", "// Add Drupal Twig parser to include trans tag.", "$", "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. @return \Symfony\Bridge\Twig\Command\LintCommand
[ "Creates", "the", "Twig", "lint", "command", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Validate/TwigCommand.php#L105-L160
train
acquia/blt
src/Robo/Wizards/SetupWizard.php
SetupWizard.wizardGenerateSettingsFiles
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(); } } }
php
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(); } } }
[ "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. Executes blt blt:init:settings command.
[ "Wizard", "for", "generating", "setup", "files", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Wizards/SetupWizard.php#L17-L35
train
acquia/blt
src/Robo/Wizards/SetupWizard.php
SetupWizard.wizardInstallDrupal
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(); } } }
php
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(); } } }
[ "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. Executes blt drupal:install.
[ "Wizard", "for", "installing", "Drupal", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Wizards/SetupWizard.php#L42-L58
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isDrupalInstalled
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; }
php
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; }
[ "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. This method caches its result in $this->drupalIsInstalled. @return bool TRUE if Drupal is installed.
[ "Checks", "that", "Drupal", "is", "installed", "caches", "result", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L206-L213
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.getDrushStatus
public function getDrushStatus() { $status_info = (array) json_decode($this->executor->drush('status --format=json --fields=*')->run()->getMessage(), TRUE); return $status_info; }
php
public function getDrushStatus() { $status_info = (array) json_decode($this->executor->drush('status --format=json --fields=*')->run()->getMessage(), TRUE); return $status_info; }
[ "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`. @return array The result of `drush status`.
[ "Gets", "the", "result", "of", "drush", "status", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L221-L225
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isDrushAliasValid
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(); }
php
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(); }
[ "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. @param string $alias @return bool TRUE if alias is valid.
[ "Validates", "a", "drush", "alias", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L263-L270
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.getDrushMajorVersion
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; }
php
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; }
[ "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. @return int The major version of drush.
[ "Gets", "the", "major", "version", "of", "drush", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L278-L290
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isMySqlAvailable
public function isMySqlAvailable() { if (is_null($this->isMySqlAvailable)) { $this->isMySqlAvailable = $this->getMySqlAvailable(); } return $this->isMySqlAvailable; }
php
public function isMySqlAvailable() { if (is_null($this->isMySqlAvailable)) { $this->isMySqlAvailable = $this->getMySqlAvailable(); } return $this->isMySqlAvailable; }
[ "public", "function", "isMySqlAvailable", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "isMySqlAvailable", ")", ")", "{", "$", "this", "->", "isMySqlAvailable", "=", "$", "this", "->", "getMySqlAvailable", "(", ")", ";", "}", "return", "$", "this", "->", "isMySqlAvailable", ";", "}" ]
Determines if MySQL is available, caches result. This method caches its result in $this->mySqlAvailable. @return bool TRUE if MySQL is available.
[ "Determines", "if", "MySQL", "is", "available", "caches", "result", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L300-L306
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.getMySqlAvailable
public function getMySqlAvailable() { $this->logger->debug("Verifying that MySQL is available..."); /** @var \Robo\Result $result */ $result = $this->executor->drush("sqlq \"SHOW DATABASES\"") ->run(); return $result->wasSuccessful(); }
php
public function getMySqlAvailable() { $this->logger->debug("Verifying that MySQL is available..."); /** @var \Robo\Result $result */ $result = $this->executor->drush("sqlq \"SHOW DATABASES\"") ->run(); return $result->wasSuccessful(); }
[ "public", "function", "getMySqlAvailable", "(", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "\"Verifying that MySQL is available...\"", ")", ";", "/** @var \\Robo\\Result $result */", "$", "result", "=", "$", "this", "->", "executor", "->", "drush", "(", "\"sqlq \\\"SHOW DATABASES\\\"\"", ")", "->", "run", "(", ")", ";", "return", "$", "result", "->", "wasSuccessful", "(", ")", ";", "}" ]
Determines if MySQL is available. Uses MySQL credentials from Drush. This method does not cache its result. @return bool TRUE if MySQL is available.
[ "Determines", "if", "MySQL", "is", "available", ".", "Uses", "MySQL", "credentials", "from", "Drush", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L316-L323
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isDrupalVmLocallyInitialized
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; }
php
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; }
[ "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. I.E., whether Drupal VM is the default LAMP stack for BLT on local machine. @return bool TRUE if Drupal VM is initialized for the local machine.
[ "Determines", "if", "Drupal", "VM", "is", "initialized", "for", "the", "local", "machine", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L344-L352
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isDrupalVmConfigValid
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; }
php
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; }
[ "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. @return bool TRUE is Drupal VM config is valid.
[ "Determines", "if", "Drupal", "VM", "config", "is", "valid", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L360-L382
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isDrupalVmBooted
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; }
php
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; }
[ "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. @return bool TRUE if Drupal VM is booted.
[ "Determines", "if", "Drupal", "VM", "is", "booted", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L390-L406
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isVagrantPluginInstalled
public function isVagrantPluginInstalled($plugin) { $installed = (bool) $this->executor->execute("vagrant plugin list | grep '$plugin'") ->interactive(FALSE) ->silent(TRUE) ->run() ->getMessage(); return $installed; }
php
public function isVagrantPluginInstalled($plugin) { $installed = (bool) $this->executor->execute("vagrant plugin list | grep '$plugin'") ->interactive(FALSE) ->silent(TRUE) ->run() ->getMessage(); return $installed; }
[ "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. You can check to see if vagrant is installed with commandExists('vagrant'). @param string $plugin The plugin name. @return bool TRUE if the plugin is installed.
[ "Checks", "to", "see", "if", "a", "given", "vagrant", "plugin", "is", "installed", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L429-L437
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.getComposerVersion
public function getComposerVersion() { $version = $this->executor->execute("composer --version") ->interactive(FALSE) ->silent(TRUE) ->run() ->getMessage(); return $version; }
php
public function getComposerVersion() { $version = $this->executor->execute("composer --version") ->interactive(FALSE) ->silent(TRUE) ->run() ->getMessage(); return $version; }
[ "public", "function", "getComposerVersion", "(", ")", "{", "$", "version", "=", "$", "this", "->", "executor", "->", "execute", "(", "\"composer --version\"", ")", "->", "interactive", "(", "FALSE", ")", "->", "silent", "(", "TRUE", ")", "->", "run", "(", ")", "->", "getMessage", "(", ")", ";", "return", "$", "version", ";", "}" ]
Gets Composer version. @return string The version of Composer.
[ "Gets", "Composer", "version", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L451-L459
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isBltAliasInstalled
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; }
php
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; }
[ "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. @return bool TRUE if BLT alias is installed.
[ "Checks", "to", "see", "if", "BLT", "alias", "is", "installed", "on", "CLI", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L467-L477
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.getCliConfigFile
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; }
php
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; }
[ "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. @return null|string Returns file path or NULL if none was found.
[ "Determines", "the", "CLI", "config", "file", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L485-L513
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isGitMinimumVersionSatisfied
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; }
php
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; }
[ "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. @param string $minimum_version The minimum git version that is required. @return bool TRUE if minimum version is satisfied.
[ "Verifies", "that", "installed", "minimum", "git", "version", "is", "met", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L538-L544
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.getLocalBehatConfig
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; }
php
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; }
[ "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. @return \Acquia\Blt\Robo\Config\BltConfig The local Behat configuration.
[ "Gets", "the", "local", "behat", "configuration", "defined", "in", "local", ".", "yml", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L564-L575
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.filesExist
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; }
php
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; }
[ "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. @return bool TRUE if all files exist.
[ "Determines", "if", "all", "file", "in", "a", "given", "array", "exist", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L612-L621
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isBehatConfigured
public function isBehatConfigured() { // Verify that URIs required for Drupal and Behat are configured correctly. $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; } // Verify that URIs required for an ad-hoc PHP internal server are // configured correctly. 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; } } // Verify that required Behat files are present. if (!$this->areBehatConfigFilesPresent()) { return FALSE; } return TRUE; }
php
public function isBehatConfigured() { // Verify that URIs required for Drupal and Behat are configured correctly. $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; } // Verify that URIs required for an ad-hoc PHP internal server are // configured correctly. 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; } } // Verify that required Behat files are present. if (!$this->areBehatConfigFilesPresent()) { return FALSE; } return TRUE; }
[ "public", "function", "isBehatConfigured", "(", ")", "{", "// Verify that URIs required for Drupal and Behat are configured correctly.", "$", "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", ";", "}", "// Verify that URIs required for an ad-hoc PHP internal server are", "// configured correctly.", "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", ";", "}", "}", "// Verify that required Behat files are present.", "if", "(", "!", "$", "this", "->", "areBehatConfigFilesPresent", "(", ")", ")", "{", "return", "FALSE", ";", "}", "return", "TRUE", ";", "}" ]
Determines if Behat is properly configured on the local machine. This will ensure that required Behat file exists, and that require configuration values are properly defined. @return bool TRUE is Behat is properly configured on the local machine.
[ "Determines", "if", "Behat", "is", "properly", "configured", "on", "the", "local", "machine", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L632-L662
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.getCurrentSchemaVersion
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; }
php
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; }
[ "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. @return string The current schema version.
[ "Gets", "the", "current", "schema", "version", "of", "the", "root", "project", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L751-L760
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.warnIfDrupalVmNotRunning
protected function warnIfDrupalVmNotRunning() { if (!$this->isVmCli() && $this->isDrupalVmLocallyInitialized() && !$this->isDrupalVmBooted()) { $this->logger->warning("Drupal VM is locally initialized, but is not running."); } }
php
protected function warnIfDrupalVmNotRunning() { if (!$this->isVmCli() && $this->isDrupalVmLocallyInitialized() && !$this->isDrupalVmBooted()) { $this->logger->warning("Drupal VM is locally initialized, but is not running."); } }
[ "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.
[ "Emits", "a", "warning", "if", "Drupal", "VM", "is", "initialized", "but", "not", "running", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L772-L776
train
acquia/blt
src/Robo/Inspector/Inspector.php
Inspector.isActiveConfigIdentical
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; }
php
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; }
[ "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. @return bool TRUE if config is identical.
[ "Determines", "if", "the", "active", "config", "is", "identical", "to", "sync", "directory", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Inspector/Inspector.php#L831-L838
train
acquia/blt
src/Robo/Tasks/DrushTask.php
DrushTask.drush
public function drush($command) { // Clear out options associated with previous drush command. $this->setOptionsForLastCommand(); if (!$this->defaultsInitialized) { $this->init(); } if (is_array($command)) { $command = implode(' ', array_filter($command)); } $this->commands[] = trim($command); return $this; }
php
public function drush($command) { // Clear out options associated with previous drush command. $this->setOptionsForLastCommand(); if (!$this->defaultsInitialized) { $this->init(); } if (is_array($command)) { $command = implode(' ', array_filter($command)); } $this->commands[] = trim($command); return $this; }
[ "public", "function", "drush", "(", "$", "command", ")", "{", "// Clear out options associated with previous 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. @param string $command The drush command to execute. Do NOT include "drush" prefix. @return $this
[ "Adds", "the", "given", "drush", "command", "to", "a", "stack", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Tasks/DrushTask.php#L112-L126
train
acquia/blt
src/Robo/Tasks/DrushTask.php
DrushTask.init
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; }
php
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; }
[ "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.
[ "Sets", "up", "drush", "defaults", "using", "config", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Tasks/DrushTask.php#L236-L261
train
acquia/blt
src/Robo/Tasks/DrushTask.php
DrushTask.mixedToBool
protected function mixedToBool($mixedVar) { if (is_string($mixedVar)) { $boolVar = ($mixedVar === 'yes' || $mixedVar === 'true'); } else { $boolVar = (bool) $mixedVar; } return $boolVar; }
php
protected function mixedToBool($mixedVar) { if (is_string($mixedVar)) { $boolVar = ($mixedVar === 'yes' || $mixedVar === 'true'); } else { $boolVar = (bool) $mixedVar; } return $boolVar; }
[ "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. @param mixed $mixedVar @return bool TRUE/FALSE as per PHP's cast to boolean ruleset, with the exception that a string value not equal to 'yes' or 'true' will evaluate to FALSE.
[ "Helper", "function", "to", "get", "the", "boolean", "equivalent", "of", "a", "variable", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Tasks/DrushTask.php#L272-L280
train
acquia/blt
src/Robo/Tasks/DrushTask.php
DrushTask.setOptionsForLastCommand
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}"); } }
php
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}"); } }
[ "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.
[ "Associates", "arguments", "with", "their", "corresponding", "drush", "command", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Tasks/DrushTask.php#L285-L295
train
acquia/blt
src/Robo/Tasks/DrushTask.php
DrushTask.setGlobalOptions
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"); } }
php
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"); } }
[ "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.
[ "Set", "the", "options", "to", "be", "used", "for", "each", "drush", "command", "in", "the", "stack", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Tasks/DrushTask.php#L300-L350
train
acquia/blt
src/Robo/Tasks/DrushTask.php
DrushTask.setupExecution
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] : ''; // Add in global options, as well as those set via option method. $command = $command . $options . $globalOptions; $this->exec($command) ->dir($this->dir); } }
php
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] : ''; // Add in global options, as well as those set via option method. $command = $command . $options . $globalOptions; $this->exec($command) ->dir($this->dir); } }
[ "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", "]", ":", "''", ";", "// Add in global options, as well as those set via option method.", "$", "command", "=", "$", "command", ".", "$", "options", ".", "$", "globalOptions", ";", "$", "this", "->", "exec", "(", "$", "command", ")", "->", "dir", "(", "$", "this", "->", "dir", ")", ";", "}", "}" ]
Adds drush commands with their corresponding options to stack.
[ "Adds", "drush", "commands", "with", "their", "corresponding", "options", "to", "stack", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Tasks/DrushTask.php#L403-L422
train
acquia/blt
src/Robo/Commands/Doctor/FileSystemCheck.php
FileSystemCheck.checkFileSystem
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'); } } }
php
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'); } } }
[ "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.
[ "Checks", "that", "configured", "file", "system", "paths", "exist", "and", "are", "writable", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Doctor/FileSystemCheck.php#L17-L67
train
acquia/blt
src/Robo/Commands/Fix/PhpCbfCommand.php
PhpCbfCommand.phpcbfFileSet
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(); // - 0 indicates that no fixable errors were found. // - 1 indicates that all fixable errors were fixed correctly. // - 2 indicates that PHPCBF failed to fix some of the fixable errors. // - 3 is used for general script execution errors. 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."); } }
php
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(); // - 0 indicates that no fixable errors were found. // - 1 indicates that all fixable errors were fixed correctly. // - 2 indicates that PHPCBF failed to fix some of the fixable errors. // - 3 is used for general script execution errors. 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."); } }
[ "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", "(", ")", ";", "// - 0 indicates that no fixable errors were found.", "// - 1 indicates that all fixable errors were fixed correctly.", "// - 2 indicates that PHPCBF failed to fix some of the fixable errors.", "// - 3 is used for general script execution errors.", "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. @command source:fix:php-standards @aliases sfps fix phpcbf fix:phpcbf
[ "Fixes", "and", "beautifies", "custom", "code", "according", "to", "Drupal", "Coding", "standards", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Fix/PhpCbfCommand.php#L20-L50
train
acquia/blt
src/Robo/Datastore/FileStore.php
FileStore.get
public function get($key) { $out = NULL; // Read the json encoded value from disk if it exists. $path = $this->getFileName($key); if (file_exists($path)) { $out = file_get_contents($path); $out = json_decode($out, TRUE); } return $out; }
php
public function get($key) { $out = NULL; // Read the json encoded value from disk if it exists. $path = $this->getFileName($key); if (file_exists($path)) { $out = file_get_contents($path); $out = json_decode($out, TRUE); } return $out; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "out", "=", "NULL", ";", "// Read the json encoded value from disk if it exists.", "$", "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. @param string $key A key. @return mixed The value fpr the given key or null.
[ "Reads", "retrieves", "data", "from", "the", "store", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Datastore/FileStore.php#L29-L38
train
acquia/blt
src/Robo/Datastore/FileStore.php
FileStore.set
public function set($key, $data) { $path = $this->getFileName($key, TRUE); file_put_contents($path, json_encode($data)); }
php
public function set($key, $data) { $path = $this->getFileName($key, TRUE); file_put_contents($path, json_encode($data)); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "data", ")", "{", "$", "path", "=", "$", "this", "->", "getFileName", "(", "$", "key", ",", "TRUE", ")", ";", "file_put_contents", "(", "$", "path", ",", "json_encode", "(", "$", "data", ")", ")", ";", "}" ]
Saves a value with the given key. @param string $key A key. @param mixed $data Data to save to the store.
[ "Saves", "a", "value", "with", "the", "given", "key", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Datastore/FileStore.php#L48-L51
train
acquia/blt
src/Robo/Datastore/FileStore.php
FileStore.remove
public function remove($key) { $path = $this->getFileName($key, TRUE); if (file_exists($path)) { unlink($path); } }
php
public function remove($key) { $path = $this->getFileName($key, TRUE); if (file_exists($path)) { unlink($path); } }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "$", "path", "=", "$", "this", "->", "getFileName", "(", "$", "key", ",", "TRUE", ")", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "unlink", "(", "$", "path", ")", ";", "}", "}" ]
Remove value from the store. @param string $key A key.
[ "Remove", "value", "from", "the", "store", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Datastore/FileStore.php#L72-L77
train
acquia/blt
src/Robo/Datastore/FileStore.php
FileStore.keys
public function keys() { $root = $this->directory; if (file_exists($root) && is_readable($root)) { return array_diff(scandir($root), array('..', '.')); } return []; }
php
public function keys() { $root = $this->directory; if (file_exists($root) && is_readable($root)) { return array_diff(scandir($root), array('..', '.')); } return []; }
[ "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. @return array A list of keys
[ "Return", "a", "list", "of", "all", "keys", "in", "the", "store", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Datastore/FileStore.php#L93-L99
train
acquia/blt
src/Robo/Datastore/FileStore.php
FileStore.getFileName
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; }
php
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; }
[ "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. @param string $key The data key to be written or read. @return string A file path @throws \Exception
[ "Get", "a", "valid", "file", "name", "for", "the", "given", "key", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Datastore/FileStore.php#L111-L122
train
acquia/blt
src/Robo/Datastore/FileStore.php
FileStore.ensureDirectoryWritable
protected function ensureDirectoryWritable() { // Reality check to prevent stomping on the local filesystem if there is // something wrong with the config. 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] ); } }
php
protected function ensureDirectoryWritable() { // Reality check to prevent stomping on the local filesystem if there is // something wrong with the config. 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] ); } }
[ "protected", "function", "ensureDirectoryWritable", "(", ")", "{", "// Reality check to prevent stomping on the local filesystem if there is", "// something wrong with the config.", "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.
[ "Check", "that", "the", "directory", "is", "writable", "and", "create", "it", "if", "we", "can", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Datastore/FileStore.php#L141-L156
train
acquia/blt
src/Robo/Commands/Blt/AliasCommand.php
AliasCommand.installBltAlias
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>"); } }
php
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>"); } }
[ "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. @command blt:init:shell-alias @aliases alias install-alias
[ "Installs", "the", "BLT", "alias", "for", "command", "line", "usage", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Blt/AliasCommand.php#L21-L57
train
acquia/blt
src/Robo/Commands/Blt/AliasCommand.php
AliasCommand.createNewAlias
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."); } }
php
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."); } }
[ "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.
[ "Creates", "a", "new", "BLT", "alias", "in", "appropriate", "CLI", "config", "file", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Blt/AliasCommand.php#L62-L84
train
acquia/blt
src/Robo/Commands/Blt/AliasCommand.php
AliasCommand.getAliasInfo
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, ]; }
php
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, ]; }
[ "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. @return array An array of information about the installed BLT alias.
[ "Gets", "information", "about", "the", "installed", "BLT", "alias", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Blt/AliasCommand.php#L104-L128
train
acquia/blt
src/Robo/Commands/Blt/AliasCommand.php
AliasCommand.updateAlias
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."); }
php
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."); }
[ "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.
[ "Replaces", "installed", "alias", "with", "up", "-", "to", "-", "date", "alias", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Blt/AliasCommand.php#L133-L144
train
acquia/blt
src/Robo/Commands/Blt/AliasCommand.php
AliasCommand.getClosingBracketPosition
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; }
php
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; }
[ "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. @param $contents The string containing the brackets. @param int $start_pos The position of the opening bracket in the string that should be matched. @return int|null
[ "Find", "the", "position", "of", "a", "closing", "bracket", "for", "a", "given", "stanza", "in", "a", "string", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Blt/AliasCommand.php#L156-L172
train
acquia/blt
src/Robo/Hooks/CommandEventHook.php
CommandEventHook.skipDisabledCommands
public function skipDisabledCommands(ConsoleCommandEvent $event) { $command = $event->getCommand(); if ($this->isCommandDisabled($command->getName())) { $event->disableCommand(); } // @todo Transmit analytics on command execution. Do the same in status hook. }
php
public function skipDisabledCommands(ConsoleCommandEvent $event) { $command = $event->getCommand(); if ($this->isCommandDisabled($command->getName())) { $event->disableCommand(); } // @todo Transmit analytics on command execution. Do the same in status hook. }
[ "public", "function", "skipDisabledCommands", "(", "ConsoleCommandEvent", "$", "event", ")", "{", "$", "command", "=", "$", "event", "->", "getCommand", "(", ")", ";", "if", "(", "$", "this", "->", "isCommandDisabled", "(", "$", "command", "->", "getName", "(", ")", ")", ")", "{", "$", "event", "->", "disableCommand", "(", ")", ";", "}", "// @todo Transmit analytics on command execution. Do the same in status hook.", "}" ]
Disable any command listed in the `disable-target` config key. @hook command-event *
[ "Disable", "any", "command", "listed", "in", "the", "disable", "-", "target", "config", "key", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Hooks/CommandEventHook.php#L21-L28
train
acquia/blt
src/Robo/Commands/Validate/PhpcsCommand.php
PhpcsCommand.sniffFileSets
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."); } } }
php
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."); } } }
[ "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. By default, these include custom themes, modules, and tests. @command tests:phpcs:sniff:all @aliases tpsa phpcs tests:phpcs:sniff validate:phpcs
[ "Executes", "PHP", "Code", "Sniffer", "against", "all", "phpcs", ".", "filesets", "files", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Validate/PhpcsCommand.php#L22-L39
train
acquia/blt
src/Robo/Commands/Validate/PhpcsCommand.php
PhpcsCommand.sniffFileList
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; }
php
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; }
[ "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. This command will execute PHP Codesniffer against a list of files if those files are a subset of the phpcs.filesets filesets. @command tests:phpcs:sniff:files @aliases tpsf @param string $file_list A list of files to scan, separated by \n. @return int
[ "Executes", "PHP", "Code", "Sniffer", "against", "a", "list", "of", "files", "if", "in", "phpcs", ".", "filesets", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Validate/PhpcsCommand.php#L66-L83
train
acquia/blt
src/Robo/Commands/Acsf/AcsfCommand.php
AcsfCommand.printPreamble
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>"); }
php
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>"); }
[ "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.
[ "Prints", "information", "about", "the", "command", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Acsf/AcsfCommand.php#L18-L30
train
acquia/blt
src/Robo/Commands/Acsf/AcsfCommand.php
AcsfCommand.acsfInitialize
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); }
php
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); }
[ "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. @command recipes:acsf:init:all @aliases acsf acsf:init @options acsf-version
[ "Initializes", "ACSF", "support", "for", "project", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Acsf/AcsfCommand.php#L40-L74
train
acquia/blt
src/Robo/Commands/Acsf/AcsfCommand.php
AcsfCommand.acsfDrushInitialize
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; }
php
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; }
[ "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. @command recipes:acsf:init:drush @aliases raid acsf:init:drush
[ "Refreshes", "the", "ACSF", "settings", "and", "hook", "files", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Acsf/AcsfCommand.php#L83-L95
train
acquia/blt
src/Robo/Commands/Acsf/AcsfCommand.php
AcsfCommand.downloadDrush8
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); }
php
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); }
[ "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. @param string $destination Download destination.
[ "Download", "drush", "8", "binary", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Acsf/AcsfCommand.php#L126-L139
train
acquia/blt
src/Robo/Commands/Setup/BuildCommand.php
BuildCommand.composerInstall
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; }
php
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; }
[ "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. @command source:build:composer @aliases sbc setup:composer:install
[ "Installs", "Composer", "dependencies", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/BuildCommand.php#L102-L113
train
acquia/blt
src/Robo/Common/ArrayManipulator.php
ArrayManipulator.expandFromDotNotatedKeys
public static function expandFromDotNotatedKeys(array $array) { $data = new Data(); // @todo Make this work at all levels of array. foreach ($array as $key => $value) { $data->set($key, $value); } return $data->export(); }
php
public static function expandFromDotNotatedKeys(array $array) { $data = new Data(); // @todo Make this work at all levels of array. foreach ($array as $key => $value) { $data->set($key, $value); } return $data->export(); }
[ "public", "static", "function", "expandFromDotNotatedKeys", "(", "array", "$", "array", ")", "{", "$", "data", "=", "new", "Data", "(", ")", ";", "// @todo Make this work at all levels of array.", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "data", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "data", "->", "export", "(", ")", ";", "}" ]
Converts dot-notated keys to proper associative nested keys. E.g., [drush.alias => 'self'] would be expanded to ['drush' => ['alias' => 'self']] @param array $array The array containing unexpanded dot-notated keys. @return array The expanded array.
[ "Converts", "dot", "-", "notated", "keys", "to", "proper", "associative", "nested", "keys", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Common/ArrayManipulator.php#L54-L63
train
acquia/blt
src/Robo/Common/ArrayManipulator.php
ArrayManipulator.flattenMultidimensionalArray
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; }
php
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; }
[ "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. This is the inverse of expandFromDotNotatedKeys(), e.g., ['drush' => ['alias' => 'self']] would be flattened to [drush.alias => 'self']. @param array $array The multidimensional array. @param string $glue The character(s) to use for imploding keys. @return array The flattened array.
[ "Flattens", "a", "multidimensional", "array", "to", "a", "flat", "array", "using", "custom", "glue", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Common/ArrayManipulator.php#L97-L109
train
acquia/blt
src/Robo/Common/ArrayManipulator.php
ArrayManipulator.convertArrayToFlatTextArray
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; }
php
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; }
[ "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. Used primarily for rendering tables via Symfony Console commands. @param array $array The multi-dimensional array. @return array The human-readble, flat array.
[ "Converts", "a", "multi", "-", "dimensional", "array", "to", "a", "human", "-", "readable", "flat", "array", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Common/ArrayManipulator.php#L122-L156
train
acquia/blt
src/Robo/Commands/Blt/ConfigCommand.php
ConfigCommand.getValue
public function getValue($key) { if (!$this->getConfig()->has($key)) { throw new BltException("$key is not set."); } $this->say($this->getConfigValue($key)); }
php
public function getValue($key) { if (!$this->getConfig()->has($key)) { throw new BltException("$key is not set."); } $this->say($this->getConfigValue($key)); }
[ "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. @command blt:config:get @aliases bcg config:get @param string $key The key for the configuration item to get. @throws \Acquia\Blt\Robo\Exceptions\BltException
[ "Gets", "the", "value", "of", "a", "config", "variable", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Blt/ConfigCommand.php#L25-L31
train
acquia/blt
src/Robo/Commands/Blt/ConfigCommand.php
ConfigCommand.dump
public function dump() { $config = $this->getConfig()->export(); ksort($config); $this->printArrayAsTable($config); }
php
public function dump() { $config = $this->getConfig()->export(); ksort($config); $this->printArrayAsTable($config); }
[ "public", "function", "dump", "(", ")", "{", "$", "config", "=", "$", "this", "->", "getConfig", "(", ")", "->", "export", "(", ")", ";", "ksort", "(", "$", "config", ")", ";", "$", "this", "->", "printArrayAsTable", "(", "$", "config", ")", ";", "}" ]
Dumps all configuration values. @command blt:config:dump @aliases bcd dump config:dump
[ "Dumps", "all", "configuration", "values", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Blt/ConfigCommand.php#L40-L44
train
acquia/blt
src/Robo/Common/YamlMunge.php
YamlMunge.mungeFiles
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); }
php
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); }
[ "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. @param string $file1 The file path of the first file. @param string $file2 The file path of the second file. @return array The merged arrays.
[ "Merges", "the", "arrays", "in", "two", "yaml", "files", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Common/YamlMunge.php#L24-L29
train
acquia/blt
src/Robo/Common/YamlMunge.php
YamlMunge.arrayMergeRecursiveExceptEmpty
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; }
php
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; }
[ "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. Preserves data types. If value in second array is empty, it will REPLACE the corresponding key in the first array, rather than being merged. @param array $array1 The first array. @param array $array2 The second array. @return array
[ "Recursively", "merges", "arrays", "UNLESS", "second", "array", "is", "empty", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Common/YamlMunge.php#L91-L104
train
acquia/blt
src/Robo/Commands/Validate/AcsfCommand.php
AcsfCommand.validateAcsf
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."); } }
php
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."); } }
[ "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. @command tests:acsf:validate
[ "Executes", "the", "acsf", "-", "init", "-", "validate", "command", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Validate/AcsfCommand.php#L18-L27
train
acquia/blt
src/Robo/Commands/Setup/SettingsCommand.php
SettingsCommand.installGitHook
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..."); } } }
php
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..."); } } }
[ "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. This symlinks the hook into the project's .git/hooks directory. @param string $hook The git hook to install, e.g., 'pre-commit'. @throws \Acquia\Blt\Robo\Exceptions\BltException
[ "Installs", "a", "given", "git", "hook", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/SettingsCommand.php#L251-L289
train
acquia/blt
src/Robo/Commands/Setup/ConfigCommand.php
ConfigCommand.update
public function update() { $task = $this->taskDrush() ->stopOnFail() // Execute db updates. // This must happen before features are imported or configuration is // imported. For instance, if you add a dependency on a new extension to // an existing configuration file, you must enable that extension via an // update hook before attempting to import the configuration. // If a db update relies on updated configuration, you should import the // necessary configuration file(s) as part of the db update. ->drush("updb"); $result = $task->run(); if (!$result->wasSuccessful()) { throw new BltException("Failed to execute database updates!"); } $this->invokeCommands(['drupal:config:import', 'drupal:toggle:modules']); }
php
public function update() { $task = $this->taskDrush() ->stopOnFail() // Execute db updates. // This must happen before features are imported or configuration is // imported. For instance, if you add a dependency on a new extension to // an existing configuration file, you must enable that extension via an // update hook before attempting to import the configuration. // If a db update relies on updated configuration, you should import the // necessary configuration file(s) as part of the db update. ->drush("updb"); $result = $task->run(); if (!$result->wasSuccessful()) { throw new BltException("Failed to execute database updates!"); } $this->invokeCommands(['drupal:config:import', 'drupal:toggle:modules']); }
[ "public", "function", "update", "(", ")", "{", "$", "task", "=", "$", "this", "->", "taskDrush", "(", ")", "->", "stopOnFail", "(", ")", "// Execute db updates.", "// This must happen before features are imported or configuration is", "// imported. For instance, if you add a dependency on a new extension to", "// an existing configuration file, you must enable that extension via an", "// update hook before attempting to import the configuration.", "// If a db update relies on updated configuration, you should import the", "// necessary configuration file(s) as part of the db update.", "->", "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. @command drupal:update @aliases du setup:update @executeInVm
[ "Update", "current", "database", "to", "reflect", "the", "state", "of", "the", "Drupal", "file", "system", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/ConfigCommand.php#L21-L39
train
acquia/blt
src/Robo/Commands/Setup/ConfigCommand.php
ConfigCommand.import
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 using core-only or config-split strategies, first check to see if // required config is exported. 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."); // This is not considered a failure. return 0; } } // If exported site UUID does not match site active site UUID, set active // to equal exported. // @see https://www.drupal.org/project/drupal/issues/1613424 $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')) { // @codingStandardsIgnoreLine $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; } }
php
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 using core-only or config-split strategies, first check to see if // required config is exported. 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."); // This is not considered a failure. return 0; } } // If exported site UUID does not match site active site UUID, set active // to equal exported. // @see https://www.drupal.org/project/drupal/issues/1613424 $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')) { // @codingStandardsIgnoreLine $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; } }
[ "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 using core-only or config-split strategies, first check to see if", "// required config is exported.", "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.\"", ")", ";", "// This is not considered a failure.", "return", "0", ";", "}", "}", "// If exported site UUID does not match site active site UUID, set active", "// to equal exported.", "// @see https://www.drupal.org/project/drupal/issues/1613424", "$", "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'", ")", ")", "{", "// @codingStandardsIgnoreLine", "$", "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. @command drupal:config:import @aliases dci setup:config-import @validateDrushConfig @executeInVm
[ "Imports", "configuration", "from", "the", "config", "directory", "according", "to", "cm", ".", "strategy", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/ConfigCommand.php#L50-L111
train
acquia/blt
src/Robo/Commands/Setup/ConfigCommand.php
ConfigCommand.importConfigSplit
protected function importConfigSplit($task, $cm_core_key) { $task->drush("pm-enable")->arg('config_split'); $task->drush("config-import")->arg($cm_core_key); // Runs a second import to ensure splits are // both defined and imported. $task->drush("config-import")->arg($cm_core_key); }
php
protected function importConfigSplit($task, $cm_core_key) { $task->drush("pm-enable")->arg('config_split'); $task->drush("config-import")->arg($cm_core_key); // Runs a second import to ensure splits are // both defined and imported. $task->drush("config-import")->arg($cm_core_key); }
[ "protected", "function", "importConfigSplit", "(", "$", "task", ",", "$", "cm_core_key", ")", "{", "$", "task", "->", "drush", "(", "\"pm-enable\"", ")", "->", "arg", "(", "'config_split'", ")", ";", "$", "task", "->", "drush", "(", "\"config-import\"", ")", "->", "arg", "(", "$", "cm_core_key", ")", ";", "// Runs a second import to ensure splits are", "// both defined and imported.", "$", "task", "->", "drush", "(", "\"config-import\"", ")", "->", "arg", "(", "$", "cm_core_key", ")", ";", "}" ]
Import configuration using config_split module. @param \Acquia\Blt\Robo\Tasks\DrushTask $task @param string $cm_core_key
[ "Import", "configuration", "using", "config_split", "module", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/ConfigCommand.php#L129-L135
train
acquia/blt
src/Robo/Commands/Setup/ConfigCommand.php
ConfigCommand.importFeatures
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')) { // Clear drush caches to register features drush commands. foreach ($this->getConfigValue('cm.features.bundle') as $bundle) { $task->drush("features-import-all")->option('bundle', $bundle); // Revert all features again! // @see https://www.drupal.org/node/2851532 $task->drush("features-import-all")->option('bundle', $bundle); } } }
php
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')) { // Clear drush caches to register features drush commands. foreach ($this->getConfigValue('cm.features.bundle') as $bundle) { $task->drush("features-import-all")->option('bundle', $bundle); // Revert all features again! // @see https://www.drupal.org/node/2851532 $task->drush("features-import-all")->option('bundle', $bundle); } } }
[ "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'", ")", ")", "{", "// Clear drush caches to register features drush commands.", "foreach", "(", "$", "this", "->", "getConfigValue", "(", "'cm.features.bundle'", ")", "as", "$", "bundle", ")", "{", "$", "task", "->", "drush", "(", "\"features-import-all\"", ")", "->", "option", "(", "'bundle'", ",", "$", "bundle", ")", ";", "// Revert all features again!", "// @see https://www.drupal.org/node/2851532", "$", "task", "->", "drush", "(", "\"features-import-all\"", ")", "->", "option", "(", "'bundle'", ",", "$", "bundle", ")", ";", "}", "}", "}" ]
Import configuration using features module. @param \Acquia\Blt\Robo\Tasks\DrushTask $task @param string $cm_core_key
[ "Import", "configuration", "using", "features", "module", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/ConfigCommand.php#L143-L156
train
acquia/blt
src/Robo/Commands/Setup/ConfigCommand.php
ConfigCommand.checkFeaturesOverrides
protected function checkFeaturesOverrides() { if ($this->getConfigValue('cm.features.no-overrides')) { // @codingStandardsIgnoreStart $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."); } } } } // @codingStandardsIgnoreEnd }
php
protected function checkFeaturesOverrides() { if ($this->getConfigValue('cm.features.no-overrides')) { // @codingStandardsIgnoreStart $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."); } } } } // @codingStandardsIgnoreEnd }
[ "protected", "function", "checkFeaturesOverrides", "(", ")", "{", "if", "(", "$", "this", "->", "getConfigValue", "(", "'cm.features.no-overrides'", ")", ")", "{", "// @codingStandardsIgnoreStart", "$", "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.\"", ")", ";", "}", "}", "}", "}", "// @codingStandardsIgnoreEnd", "}" ]
Checks whether features are overridden. @throws \Exception If cm.features.no-overrides is true, and there are features overrides an exception will be thrown.
[ "Checks", "whether", "features", "are", "overridden", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/ConfigCommand.php#L165-L190
train
acquia/blt
src/Robo/Commands/Setup/ConfigCommand.php
ConfigCommand.getExportedSiteUuid
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; }
php
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; }
[ "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. @param string $cm_core_key @return null
[ "Returns", "the", "site", "UUID", "stored", "in", "exported", "configuration", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/ConfigCommand.php#L212-L222
train
acquia/blt
src/Robo/Commands/Blt/DevCommand.php
DevCommand.linkComposer
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(); }
php
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(); }
[ "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. @command blt:dev:link-composer @param array $options
[ "Links", "to", "a", "local", "BLT", "package", "via", "a", "Composer", "path", "repository", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Blt/DevCommand.php#L19-L33
train
acquia/blt
src/Robo/Hooks/ValidateHook.php
ValidateHook.validateSettingsFileIsValid
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."); } }
php
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."); } }
[ "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. @hook validate @validateSettingsFileIsValid
[ "Checks", "active", "settings", ".", "php", "file", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Hooks/ValidateHook.php#L76-L84
train
acquia/blt
src/Robo/Hooks/ValidateHook.php
ValidateHook.validateVmConfig
public function validateVmConfig() { if ($this->getInspector()->isDrupalVmLocallyInitialized() && $this->getInspector()->isDrupalVmBooted() && !$this->getInspector()->isDrupalVmConfigValid()) { throw new BltException("Drupal VM configuration is invalid."); } }
php
public function validateVmConfig() { if ($this->getInspector()->isDrupalVmLocallyInitialized() && $this->getInspector()->isDrupalVmBooted() && !$this->getInspector()->isDrupalVmConfigValid()) { throw new BltException("Drupal VM configuration is invalid."); } }
[ "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. @hook validate validateVmConfig
[ "Validates", "that", "current", "PHP", "process", "is", "being", "executed", "inside", "of", "the", "VM", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Hooks/ValidateHook.php#L117-L121
train
acquia/blt
src/Robo/Hooks/ValidateHook.php
ValidateHook.validateGitConfig
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'); } } }
php
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'); } } }
[ "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. @hook validate @validateGitConfig
[ "Validates", "that", "Git", "user", "is", "configured", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Hooks/ValidateHook.php#L128-L139
train
acquia/blt
src/Robo/Commands/Git/GitCommand.php
GitCommand.commitMsgHook
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; }
php
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; }
[ "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. @command internal:git-hook:execute:commit-msg @aliases git:commit-msg @hidden @return int
[ "Validates", "a", "git", "commit", "message", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Git/GitCommand.php#L22-L43
train
acquia/blt
src/Robo/Commands/Git/GitCommand.php
GitCommand.preCommitHook
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; }
php
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; }
[ "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. @command internal:git-hook:execute:pre-commit @aliases git:pre-commit @hidden @param string $changed_files A list of staged files, separated by \n. @return \Robo\Result
[ "Validates", "staged", "files", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Git/GitCommand.php#L57-L89
train
acquia/blt
src/Robo/Hooks/DrushHook.php
DrushHook.validateDrushConfig
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'."); } }
php
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'."); } }
[ "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. @hook validate @validateDrushConfig
[ "Validates", "drush", "configuration", "for", "failed", "commands", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Hooks/DrushHook.php#L19-L29
train
acquia/blt
src/Robo/Common/TextMunge.php
TextMunge.munge
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; }
php
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; }
[ "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. @param string $file1 The file path of the first file. @param string $file2 The file path of the second file. @return string The merged arrays, in yaml format.
[ "Merges", "the", "arrays", "in", "two", "text", "files", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Common/TextMunge.php#L23-L30
train
acquia/blt
src/Robo/Common/TextMunge.php
TextMunge.arrayMergeNoDuplicates
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; }
php
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; }
[ "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. @param array $array1 The first array. @param array $array2 The second array. @return array
[ "Merges", "two", "arrays", "and", "removes", "duplicate", "values", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Common/TextMunge.php#L42-L48
train
acquia/blt
src/Robo/Commands/Validate/AllCommand.php
AllCommand.all
public function all() { $commands = [ 'tests:composer:validate', 'tests:php:lint', 'tests:phpcs:sniff:all', 'tests:yaml:lint:all', 'tests:twig:lint:all', ]; // To enable this command, set validate.acsf to TRUE in blt.yml. if ($this->getConfigValue('validate.acsf') == TRUE) { $commands[] = 'tests:acsf:validate'; } $status_code = $this->invokeCommands($commands); return $status_code; }
php
public function all() { $commands = [ 'tests:composer:validate', 'tests:php:lint', 'tests:phpcs:sniff:all', 'tests:yaml:lint:all', 'tests:twig:lint:all', ]; // To enable this command, set validate.acsf to TRUE in blt.yml. if ($this->getConfigValue('validate.acsf') == TRUE) { $commands[] = 'tests:acsf:validate'; } $status_code = $this->invokeCommands($commands); return $status_code; }
[ "public", "function", "all", "(", ")", "{", "$", "commands", "=", "[", "'tests:composer:validate'", ",", "'tests:php:lint'", ",", "'tests:phpcs:sniff:all'", ",", "'tests:yaml:lint:all'", ",", "'tests:twig:lint:all'", ",", "]", ";", "// To enable this command, set validate.acsf to TRUE in blt.yml.", "if", "(", "$", "this", "->", "getConfigValue", "(", "'validate.acsf'", ")", "==", "TRUE", ")", "{", "$", "commands", "[", "]", "=", "'tests:acsf:validate'", ";", "}", "$", "status_code", "=", "$", "this", "->", "invokeCommands", "(", "$", "commands", ")", ";", "return", "$", "status_code", ";", "}" ]
Runs all code validation commands. @command validate @aliases validate:all @hidden
[ "Runs", "all", "code", "validation", "commands", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Validate/AllCommand.php#L19-L34
train
acquia/blt
src/Robo/Commands/Doctor/ComposerCheck.php
ComposerCheck.performAllChecks
public function performAllChecks() { $this->checkRequire(); $this->checkBltRequireDev(); if (!$this->getInspector()->isVmCli()) { $this->checkPrestissimo(); } $this->checkComposerConfig(); return $this->problems; }
php
public function performAllChecks() { $this->checkRequire(); $this->checkBltRequireDev(); if (!$this->getInspector()->isVmCli()) { $this->checkPrestissimo(); } $this->checkComposerConfig(); return $this->problems; }
[ "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.
[ "Checks", "that", "composer", ".", "json", "is", "configured", "correctly", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Doctor/ComposerCheck.php#L105-L114
train
acquia/blt
src/Robo/Commands/Doctor/ComposerCheck.php
ComposerCheck.checkComposerConfig
protected function checkComposerConfig() { // @todo specify third key Acquia\\Blt\\Custom\\. $this->compareComposerConfig('autoload', 'psr-4'); // @todo specify third key Drupal\\Tests\\PHPUnit\\\. $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'); }
php
protected function checkComposerConfig() { // @todo specify third key Acquia\\Blt\\Custom\\. $this->compareComposerConfig('autoload', 'psr-4'); // @todo specify third key Drupal\\Tests\\PHPUnit\\\. $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'); }
[ "protected", "function", "checkComposerConfig", "(", ")", "{", "// @todo specify third key Acquia\\\\Blt\\\\Custom\\\\.", "$", "this", "->", "compareComposerConfig", "(", "'autoload'", ",", "'psr-4'", ")", ";", "// @todo specify third key Drupal\\\\Tests\\\\PHPUnit\\\\\\.", "$", "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.
[ "Emits", "a", "warning", "if", "project", "Composer", "config", "is", "different", "than", "default", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Doctor/ComposerCheck.php#L140-L152
train
acquia/blt
src/Robo/Commands/Doctor/WebUriCheck.php
WebUriCheck.checkUriResponse
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'); } }
php
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'); } }
[ "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.
[ "Checks", "that", "configured", "URI", "responds", "to", "requests", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Doctor/WebUriCheck.php#L40-L51
train
acquia/blt
src/Robo/Commands/Doctor/WebUriCheck.php
WebUriCheck.checkHttps
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'); } } }
php
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'); } } }
[ "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.
[ "Checks", "that", "SSL", "cert", "is", "valid", "for", "configured", "URI", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Doctor/WebUriCheck.php#L56-L64
train
acquia/blt
src/Robo/Commands/Setup/WizardCommand.php
WizardCommand.wizard
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', ], ]); } }
php
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', ], ]); } }
[ "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. @command wizard
[ "Wizard", "for", "setting", "initial", "configuration", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/WizardCommand.php#L26-L57
train
acquia/blt
src/Robo/Commands/Setup/WizardCommand.php
WizardCommand.loadRecipeFile
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; }
php
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; }
[ "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. @param string $filename The recipe filename. @return array
[ "Load", "a", "recipe", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/WizardCommand.php#L67-L83
train
acquia/blt
src/Robo/Commands/Setup/WizardCommand.php
WizardCommand.askForAnswers
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; }
php
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; }
[ "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. @return array An array of answers.
[ "Prompts", "the", "user", "for", "information", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Setup/WizardCommand.php#L91-L132
train
acquia/blt
src/Robo/Commands/Validate/ComposerCommand.php
ComposerCommand.validate
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!"); } }
php
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!"); } }
[ "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. @command tests:composer:validate @aliases tcv validate:composer
[ "Validates", "root", "composer", ".", "json", "and", "composer", ".", "lock", "files", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Validate/ComposerCommand.php#L20-L33
train
acquia/blt
src/Robo/Commands/Doctor/ConfigCheck.php
ConfigCheck.checkDeprecatedKeys
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'); } }
php
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'); } }
[ "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.
[ "Checks", "that", "is", "configured", "correctly", "at", "a", "high", "level", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Doctor/ConfigCheck.php#L30-L51
train
acquia/blt
src/Robo/Commands/Vm/VmCommand.php
VmCommand.vm
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; } } // @todo Check that VM is properly configured, e.g., all config files exist // and geerlingguy/drupalvm is in composer.lock. 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(); } }
php
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; } } // @todo Check that VM is properly configured, e.g., all config files exist // and geerlingguy/drupalvm is in composer.lock. 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(); } }
[ "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", ";", "}", "}", "// @todo Check that VM is properly configured, e.g., all config files exist", "// and geerlingguy/drupalvm is in composer.lock.", "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. @command recipes:drupalvm:init @aliases rdi vm @options no-boot @throws \Exception
[ "Configures", "and", "boots", "a", "Drupal", "VM", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Vm/VmCommand.php#L61-L84
train
acquia/blt
src/Robo/Commands/Vm/VmCommand.php
VmCommand.nuke
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) // @todo More surgically remove drush.default_alias and drush.aliases.local values from this file // rather than overwriting it. ->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."); } }
php
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) // @todo More surgically remove drush.default_alias and drush.aliases.local values from this file // rather than overwriting it. ->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."); } }
[ "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", ")", "// @todo More surgically remove drush.default_alias and drush.aliases.local values from this file", "// rather than overwriting it.", "->", "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. @command recipes:drupalvm:destroy @aliases rdd vm:nuke @throws \Exception
[ "Destroys", "existing", "VM", "and", "all", "related", "configuration", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Vm/VmCommand.php#L93-L112
train
acquia/blt
src/Robo/Commands/Vm/VmCommand.php
VmCommand.config
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(""); }
php
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(""); }
[ "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.
[ "Generates", "default", "configuration", "for", "Drupal", "VM", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Vm/VmCommand.php#L128-L148
train
acquia/blt
src/Robo/Commands/Vm/VmCommand.php
VmCommand.localInitialize
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."); }
php
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."); }
[ "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.
[ "Configures", "local", "machine", "to", "use", "Drupal", "VM", "as", "default", "env", "for", "BLT", "commands", "." ]
8a903c1d930f82f4b9ee657d62d123782dd2ed59
https://github.com/acquia/blt/blob/8a903c1d930f82f4b9ee657d62d123782dd2ed59/src/Robo/Commands/Vm/VmCommand.php#L153-L167
train