c085847ba59dc303d4c400772ec0ed1699d035e5
[yaffs-website] / vendor / drush / drush / examples / Commands / SiteAliasAlterCommands.php
1 <?php
2 namespace Drush\Commands;
3
4 use Consolidation\AnnotatedCommand\AnnotationData;
5 use Consolidation\SiteAlias\SiteAliasManagerAwareInterface;
6 use Consolidation\SiteAlias\SiteAliasManagerAwareTrait;
7 use Symfony\Component\Console\Input\InputInterface;
8
9 /**
10  * Load this example by using the --include option - e.g. `drush --include=/path/to/drush/examples`
11  */
12 class SiteAliasAlterCommands extends DrushCommands implements SiteAliasManagerAwareInterface
13 {
14
15     use SiteAliasManagerAwareTrait;
16
17   /**
18    * A few example alterations to site aliases.
19    *
20    * @hook pre-init *
21    *
22    * @param \Symfony\Component\Console\Input\InputInterface $input
23    * @param \Consolidation\AnnotatedCommand\AnnotationData $annotationData
24    */
25     public function alter(InputInterface $input, AnnotationData $annotationData)
26     {
27         $self = $this->siteAliasManager()->getSelf();
28         if ($self->isRemote()) {
29             // Always pass along ssh keys.
30             if (!$self->has('ssh.options')) {
31                 // Don't edit the alias - edit the general config service instead.
32                 $this->getConfig()->set('ssh.options', '-o ForwardAgent=yes');
33             }
34
35             // Change the SSH user.
36             $input->setOption('remote-user', 'mw2');
37         }
38     }
39 }