X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Fsrc%2FCommands%2Fconfig%2FConfigPullCommands.php;fp=vendor%2Fdrush%2Fdrush%2Fsrc%2FCommands%2Fconfig%2FConfigPullCommands.php;h=b94e02bd944a79dbe494f3656fb6883167877a42;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=0000000000000000000000000000000000000000;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/vendor/drush/drush/src/Commands/config/ConfigPullCommands.php b/vendor/drush/drush/src/Commands/config/ConfigPullCommands.php new file mode 100644 index 000000000..b94e02bd9 --- /dev/null +++ b/vendor/drush/drush/src/Commands/config/ConfigPullCommands.php @@ -0,0 +1,106 @@ + false, 'label' => 'sync', 'runner' => null]) + { + $global_options = Drush::redispatchOptions() + ['strict' => 0]; + + // @todo If either call is made interactive, we don't get an $return['object'] back. + $backend_options = ['interactive' => false]; + if (Drush::simulate()) { + $backend_options['backend-simulate'] = true; + } + + $export_options = [ + // Use the standard backup directory on Destination. + 'destination' => true, + 'yes' => null, + ]; + $this->logger()->notice(dt('Starting to export configuration on Target.')); + $return = drush_invoke_process($source, 'config-export', [], $global_options + $export_options, $backend_options); + if ($return['error_status']) { + throw new \Exception(dt('Config-export failed.')); + } else { + // Trailing slash assures that we transfer files and not the containing dir. + $export_path = $return['object'] . '/'; + } + + $rsync_options = [ + '--remove-source-files', + '--delete', + '--exclude=.htaccess', + ]; + if (strpos($destination, ':') === false) { + $destination .= ':%config-' . $options['label']; + } + $destinationHostPath = HostPath::create($this->siteAliasManager(), $destination); + + if (!$runner = $options['runner']) { + $sourceRecord = $this->siteAliasManager()->get($source); + $destinationRecord = $destinationHostPath->getAliasRecord(); + $runner = $sourceRecord->isRemote() && $destinationRecord->isRemote() ? $destinationRecord : '@self'; + } + $this->logger() + ->notice(dt('Starting to rsync configuration files from !source to !dest.', [ + '!source' => $source, + '!dest' => $destinationHostPath->getOriginal(), + ])); + // This comment applies similarly to sql-sync's use of core-rsync. + // Since core-rsync is a strict-handling command and drush_invoke_process() puts options at end, we can't send along cli options to rsync. + // Alternatively, add options like ssh.options to a site alias (usually on the machine that initiates the sql-sync). + $return = drush_invoke_process($runner, 'core-rsync', array_merge([ + "$source:$export_path", + $destinationHostPath->getOriginal(), + '--' + ], $rsync_options), ['yes' => true], $backend_options); + if ($return['error_status']) { + throw new \Exception(dt('Config-pull rsync failed.')); + } + + drush_backend_set_result($return['object']); + } + + /** + * @hook validate config-pull + */ + public function validateConfigPull(CommandData $commandData) + { + if ($commandData->input()->getOption('safe')) { + $return = drush_invoke_process($commandData->input() + ->getArgument('destination'), 'core-execute', ['git diff --quiet'], ['escape' => 0]); + if ($return['error_status']) { + throw new \Exception('There are uncommitted changes in your git working copy.'); + } + } + } +}